From 221b7145f1ed457161700ad1b7da0eb15cdb34e6 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Sat, 19 Jan 2019 12:00:09 +0200 Subject: [PATCH] Fix incorrect use of fs.stat --- src/plugins/uploader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/uploader.js b/src/plugins/uploader.js index 19528d8b..aa120738 100644 --- a/src/plugins/uploader.js +++ b/src/plugins/uploader.js @@ -49,7 +49,7 @@ class Uploader { do { randomName = crypto.randomBytes(8).toString("hex"); 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(() => { const slug = encodeURIComponent(path.basename(data.file.pathName));