From dc3a6a29bc5208c5a9690722bf238ff6ee7d9962 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Fri, 29 Jul 2022 15:32:23 -0400 Subject: [PATCH] fix: #10783, do not purge files without a timestamp prefix --- src/posts/uploads.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/posts/uploads.js b/src/posts/uploads.js index 9504752385..8033e8e66a 100644 --- a/src/posts/uploads.js +++ b/src/posts/uploads.js @@ -98,6 +98,10 @@ module.exports = function (Posts) { let files = await fs.readdir(_getFullPath('/files')); files = files.filter(filename => filename !== '.gitignore'); + // Exclude non-timestamped files (e.g. group covers; see gh#10783/gh#10705) + const tsPrefix = /^\d{13}\-/; + files = files.filter(filename => tsPrefix.test(filename)); + files = await Promise.all(files.map(async filename => (await Posts.uploads.isOrphan(`files/${filename}`) ? `files/${filename}` : null))); files = files.filter(Boolean);