fix: handle ENOENT on file deletion, closes #10645

This commit is contained in:
Julian Lam
2022-06-17 15:09:45 -04:00
parent 05c30677f5
commit 43f9e6c8e4
3 changed files with 9 additions and 2 deletions

View File

@@ -5,6 +5,7 @@
"strip-exif-data": "Strip EXIF Data",
"preserve-orphaned-uploads": "Keep uploaded files on disk after a post is purged",
"orphanExpiryDays": "Days to keep orphaned files",
"orphanExpiryDays-help": "After this many days, orphaned uploads will be deleted from the file system.<br />Set 0 or leave blank to disable.",
"private-extensions": "File extensions to make private",
"private-uploads-extensions-help": "Enter comma-separated list of file extensions to make private here (e.g. <code>pdf,xls,doc</code>). An empty list means all files are private.",
"resize-image-width-threshold": "Resize images if they are wider than specified width",

View File

@@ -107,6 +107,11 @@ file.delete = async function (path) {
try {
await fs.promises.unlink(path);
} catch (err) {
if (err.code === 'ENOENT') {
winston.verbose(`[file] Attempted to delete non-existent file: ${path}`);
return;
}
winston.warn(err);
}
};

View File

@@ -135,9 +135,10 @@
</div>
<div class="row">
<div class="form-group col-sm-4">
<div class="form-group col-sm-6">
<label for="orphanExpiryDays">[[admin/settings/uploads:orphanExpiryDays]]</label>
<input id="orphanExpiryDays" type="number" min="0" placeholder="0 to disable" class="form-control" data-field="orphanExpiryDays" />
<input id="orphanExpiryDays" type="number" min="0" placeholder="0" class="form-control" data-field="orphanExpiryDays" />
<p class="help-block">[[admin/settings/uploads:orphanExpiryDays-help]]</p>
</div>
</div>
</div>