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..

indiachan-spamvector
Thomas Lynch 2 years ago
parent 273ffd60f4
commit 4829bc6546
  1. 4
      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({

Loading…
Cancel
Save