Merge pull request #2985 from thelounge/xpaw/fix-fs-sync

Fix incorrect use of fs.stat
This commit is contained in:
Pavel Djundik 2019-01-21 11:13:12 +02:00 committed by GitHub
commit b81de36403
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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));