kopia lustrzana https://github.com/c9/core
do not call mkdirp unnecessarily when saving files
rodzic
85e8e415e8
commit
c21026c3fb
|
@ -738,6 +738,8 @@ module.exports = function setup(fsOptions) {
|
|||
var tempPath;
|
||||
var resolvedPath = "";
|
||||
var mode = options.mode || 0666 & ~umask;
|
||||
|
||||
var createParents = options.parents;
|
||||
|
||||
start();
|
||||
|
||||
|
@ -772,15 +774,7 @@ module.exports = function setup(fsOptions) {
|
|||
}
|
||||
|
||||
function start() {
|
||||
if (options.parents) {
|
||||
mkdirP(dirname(path), options, function(err) {
|
||||
if (err) return error(err);
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
else {
|
||||
resolve();
|
||||
}
|
||||
resolve();
|
||||
}
|
||||
|
||||
// Make sure the user has access to the directory and get the real path.
|
||||
|
@ -794,6 +788,13 @@ module.exports = function setup(fsOptions) {
|
|||
// If checkSymlinks is on we'll get an ENOENT when creating a new file.
|
||||
// In that case, just resolve the parent path and go from there.
|
||||
resolvePath(dirname(path), options, function (err, dir) {
|
||||
if (err && err.code === "ENOENT" && createParents) {
|
||||
createParents = false;
|
||||
return mkdirP(dirname(path), options, function(err) {
|
||||
if (err) return error(err);
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
if (err) return error(err);
|
||||
resolvedPath = join(dir, basename(path));
|
||||
createTempFile();
|
||||
|
|
Ładowanie…
Reference in New Issue