fix: handle ENOENT on file deletion, closes #10645

isekai-main
Julian Lam 3 years ago
parent 05c30677f5
commit 43f9e6c8e4

@ -5,6 +5,7 @@
"strip-exif-data": "Strip EXIF Data", "strip-exif-data": "Strip EXIF Data",
"preserve-orphaned-uploads": "Keep uploaded files on disk after a post is purged", "preserve-orphaned-uploads": "Keep uploaded files on disk after a post is purged",
"orphanExpiryDays": "Days to keep orphaned files", "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-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.", "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", "resize-image-width-threshold": "Resize images if they are wider than specified width",

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

@ -135,9 +135,10 @@
</div> </div>
<div class="row"> <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> <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> </div>
</div> </div>

Loading…
Cancel
Save