Fixed callbacks in mkdir and initFs

This commit is contained in:
Alex Shpak 2017-02-11 23:59:26 +01:00
parent bda4cbf2ad
commit cd2f53b525
2 changed files with 12 additions and 18 deletions

View File

@ -103,18 +103,12 @@ const Launcher = {
const create = function(stack, callback) {
if (!stack.length) {
if (callback) {
callback();
}
return callback && callback();
}
fs.mkdir(stack.shift(), err => {
if (err) {
return callback(err);
}
create(stack, callback);
});
fs.mkdir(stack.shift(), err =>
err ? callback(err) : create(stack, callback)
);
};
collect(dir, stack, () => create(stack, callback));

View File

@ -21,16 +21,16 @@ const StorageFileCache = StorageBase.extend({
const path = Launcher.getUserDataPath('OfflineFiles');
const setPath = (err) => {
this.path = err ? null : path;
return callback && callback(err);
};
Launcher.fileExists(path, exists => {
if (!exists) {
Launcher.mkdir(path, err => {
if (!err) {
this.path = path;
}
if (callback) { callback(); }
});
if (exists) {
setPath();
} else {
if (callback) { callback(); }
Launcher.mkdir(path, setPath());
}
});
},