Fix incorrect use of fs.stat

This commit is contained in:
Pavel Djundik 2019-01-19 12:00:09 +02:00 committed by GitHub
parent 6e1a73eea2
commit 221b7145f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -49,7 +49,7 @@ class Uploader {
do { do {
randomName = crypto.randomBytes(8).toString("hex"); randomName = crypto.randomBytes(8).toString("hex");
destPath = path.join(Helper.getFileUploadPath(), randomName.substring(0, 2), randomName); destPath = path.join(Helper.getFileUploadPath(), randomName.substring(0, 2), randomName);
} while (fs.stat(destPath, (err) => (err ? true : false))); } while (fs.existsSync(destPath));
fsextra.move(data.file.pathName, destPath).then(() => { fsextra.move(data.file.pathName, destPath).then(() => {
const slug = encodeURIComponent(path.basename(data.file.pathName)); const slug = encodeURIComponent(path.basename(data.file.pathName));