From 4829bc6546308d417702949deea0078784e1e74a Mon Sep 17 00:00:00 2001 From: Thomas Lynch Date: Fri, 8 Apr 2022 03:04:39 +1000 Subject: [PATCH] emptyDir() instead of remove() because remove runs into ENOTEMPTY under synthetic load of high post rates, probably because new threads get written to the folder at the same time. no ide a why emptyDir doesnt hav ethis problem.. --- models/forms/makepost.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/models/forms/makepost.js b/models/forms/makepost.js index e32a37e5..ba4778e9 100644 --- a/models/forms/makepost.js +++ b/models/forms/makepost.js @@ -3,7 +3,7 @@ const path = require('path') , { createHash, randomBytes } = require('crypto') , randomBytesAsync = require('util').promisify(randomBytes) - , { remove, pathExists, stat: fsStat } = require('fs-extra') + , { remove, emptyDir, pathExists, stat: fsStat } = require('fs-extra') , uploadDirectory = require(__dirname+'/../../helpers/files/uploadDirectory.js') , Mongo = require(__dirname+'/../../db/db.js') , Socketio = require(__dirname+'/../../socketio.js') @@ -628,7 +628,7 @@ ${res.locals.numFiles > 0 ? req.files.file.map(f => f.name+'|'+(f.phash || '')). if (enableCaptcha) { if (res.locals.board.settings.captchaMode == 2) { //only delete threads if all posts require threads, otherwise just build board pages for thread captcha - await remove(`${uploadDirectory}/html/${req.params.board}/thread/`); //not deleting json cos it doesnt need to be + await emptyDir(`${uploadDirectory}/html/${req.params.board}/thread/`); //not deleting json cos it doesnt need to be } const endPage = Math.ceil(threadLimit/10); buildQueue.push({