Skip to content

Commit

Permalink
fix: check whether path exist before return result
Browse files Browse the repository at this point in the history
  • Loading branch information
@jotadeveloper authored and sergiohgz committed Aug 13, 2019
1 parent 40b7eb9 commit a4d2af1
Showing 1 changed file with 27 additions and 13 deletions.
40 changes: 27 additions & 13 deletions plugins/local-storage/src/local-database.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,19 @@ class LocalDatabase implements IPluginStorage {
files,
(file2, cb) => {
if (validateName(file2)) {
const item = {
name: `${file}/${file2}`,
path: Path.resolve(base, storage, file, file2)
};

onPackage(item, cb);
const packagePath = Path.resolve(base, storage, file, file2);

fs.stat(packagePath, (err, stats) => {
if (_.isNil(err) === false) {
return cb(err);
}
const item = {
name: `${file}/${file2}`,
path: packagePath,
time: stats.mtime.getTime()
};
onPackage(item, cb);
});
} else {
cb();
}
Expand All @@ -97,13 +104,20 @@ class LocalDatabase implements IPluginStorage {
);
});
} else if (validateName(file)) {
onPackage(
{
name: file,
path: Path.resolve(base, storage, file)
},
cb
);
const packagePath = Path.resolve(base, storage, file);
fs.stat(packagePath, (err, stats) => {
if (_.isNil(err) === false) {
return cb(err);
}
onPackage(
{
name: file,
path: packagePath,
time: stats.mtime.getTime()
},
cb
);
});
} else {
cb();
}
Expand Down

0 comments on commit a4d2af1

Please sign in to comment.