kopia lustrzana https://github.com/c9/core
rodzic
314947fbf7
commit
40c010cffa
|
@ -350,7 +350,7 @@ module.exports = function setup(fsOptions) {
|
||||||
|
|
||||||
// This helper function doesn't follow node conventions in the callback,
|
// This helper function doesn't follow node conventions in the callback,
|
||||||
// there is no err, only entry.
|
// there is no err, only entry.
|
||||||
function createStatEntry(file, fullpath, callback, _loop) {
|
function createStatEntry(file, fullpath, callback) {
|
||||||
fs.lstat(fullpath, function (err, stat) {
|
fs.lstat(fullpath, function (err, stat) {
|
||||||
var entry = {
|
var entry = {
|
||||||
name: file
|
name: file
|
||||||
|
@ -378,29 +378,26 @@ module.exports = function setup(fsOptions) {
|
||||||
return callback(entry);
|
return callback(entry);
|
||||||
}
|
}
|
||||||
fs.readlink(fullpath, function (err, link) {
|
fs.readlink(fullpath, function (err, link) {
|
||||||
|
if (entry.name == link) {
|
||||||
|
entry.linkStatErr = "ELOOP: recursive symlink";
|
||||||
|
return callback(entry);
|
||||||
|
}
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
entry.linkErr = err.stack;
|
entry.linkErr = err.stack;
|
||||||
return callback(entry);
|
return callback(entry);
|
||||||
}
|
}
|
||||||
var fullLinkPath = pathResolve(dirname(fullpath), link);
|
|
||||||
if (!_loop) {
|
|
||||||
_loop = {fullLinkPath: fullpath, max: 100};
|
|
||||||
}
|
|
||||||
if (fullLinkPath.toLowerCase() == _loop.fullLinkPath.toLowerCase() || _loop.max --< 0) {
|
|
||||||
entry.linkErr = "ELOOP: recursive symlink";
|
|
||||||
return callback(entry);
|
|
||||||
}
|
|
||||||
entry.link = link;
|
entry.link = link;
|
||||||
resolvePath(fullLinkPath, {alreadyRooted: true}, function (err, newpath) {
|
resolvePath(pathResolve(dirname(fullpath), link), {alreadyRooted: true}, function (err, newpath) {
|
||||||
if (err) {
|
if (err) {
|
||||||
entry.linkErr = err;
|
entry.linkStatErr = err;
|
||||||
return callback(entry);
|
return callback(entry);
|
||||||
}
|
}
|
||||||
createStatEntry(basename(newpath), newpath, function (linkStat) {
|
createStatEntry(basename(newpath), newpath, function (linkStat) {
|
||||||
entry.linkStat = linkStat;
|
entry.linkStat = linkStat;
|
||||||
linkStat.fullPath = newpath.substr(base.length) || "/";
|
linkStat.fullPath = newpath.substr(base.length) || "/";
|
||||||
return callback(entry);
|
return callback(entry);
|
||||||
}, _loop);
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -561,8 +561,8 @@ define(function(require, exports, module) {
|
||||||
node.size = stat.size;
|
node.size = stat.size;
|
||||||
if (stat.mtime != undefined)
|
if (stat.mtime != undefined)
|
||||||
node.mtime = stat.mtime;
|
node.mtime = stat.mtime;
|
||||||
if (original_stat || stat.linkErr)
|
if (original_stat)
|
||||||
node.link = stat.fullPath || stat.linkErr;
|
node.link = stat.fullPath;
|
||||||
node.isFolder = isFolder;
|
node.isFolder = isFolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue