do not call mkdirp unnecessarily when saving files

pull/468/merge
nightwing 2017-12-10 00:57:34 +04:00
rodzic 85e8e415e8
commit c21026c3fb
1 zmienionych plików z 10 dodań i 9 usunięć

19
node_modules/vfs-local/localfs.js wygenerowano vendored
Wyświetl plik

@ -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();