kopia lustrzana https://github.com/c9/core
Merge pull request +15887 from c9/vfs-improve-mkfile
do not call mkdirp unnecessarily when saving filespull/468/merge
commit
7de17567e2
|
@ -739,6 +739,8 @@ module.exports = function setup(fsOptions) {
|
||||||
var resolvedPath = "";
|
var resolvedPath = "";
|
||||||
var mode = options.mode || 0666 & ~umask;
|
var mode = options.mode || 0666 & ~umask;
|
||||||
|
|
||||||
|
var createParents = options.parents;
|
||||||
|
|
||||||
start();
|
start();
|
||||||
|
|
||||||
function onData(chunk) {
|
function onData(chunk) {
|
||||||
|
@ -772,15 +774,7 @@ module.exports = function setup(fsOptions) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function start() {
|
function start() {
|
||||||
if (options.parents) {
|
|
||||||
mkdirP(dirname(path), options, function(err) {
|
|
||||||
if (err) return error(err);
|
|
||||||
resolve();
|
resolve();
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the user has access to the directory and get the real path.
|
// 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.
|
// 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.
|
// In that case, just resolve the parent path and go from there.
|
||||||
resolvePath(dirname(path), options, function (err, dir) {
|
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);
|
if (err) return error(err);
|
||||||
resolvedPath = join(dir, basename(path));
|
resolvedPath = join(dir, basename(path));
|
||||||
createTempFile();
|
createTempFile();
|
||||||
|
|
Ładowanie…
Reference in New Issue