提交 bb3bb0c7 编写于 作者: C Christof Marti

Create parent folders if they do not exist yet (fixes #19529)

上级 aa19ee1d
......@@ -120,6 +120,26 @@ function getNodeCachedDataDir() {
var dir = path.join(app.getPath('userData'), 'CachedData');
return mkdirp(dir);
}
function mkdirp(dir) {
return mkdir(dir)
.then(null, function (err) {
if (err && err.code === 'ENOENT') {
var parent = path.dirname(dir);
if (parent !== dir) { // if not arrived at root
return mkdirp(parent)
.then(function () {
return mkdir(dir);
});
}
}
throw err;
});
}
function mkdir(dir) {
return new Promise(function (resolve, reject) {
fs.mkdir(dir, function (err) {
if (err && err.code !== 'EEXIST') {
......@@ -186,5 +206,5 @@ app.once('ready', function () {
nodeCachedDataDir.then(function () {
require('./bootstrap-amd').bootstrap('vs/code/electron-main/main');
});
}, console.error);
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册