From 9df175d9413532a34dcc4e576f7ca92637730eb7 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Tue, 21 Jan 2020 23:39:30 +0100 Subject: [PATCH] delete file that are no longer needed --- app/Controllers/Http/DownloadController.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Controllers/Http/DownloadController.js b/app/Controllers/Http/DownloadController.js index fa88f1c..4e18797 100644 --- a/app/Controllers/Http/DownloadController.js +++ b/app/Controllers/Http/DownloadController.js @@ -40,8 +40,14 @@ class DownloadController { } return 0; }).slice(0, 5) - + // Save space by deleting file that doesn't appear in the recent feed + for (let f of fs.readdirSync('./public/uploads')) { + if (!file.includes(f) && (f != 'hidden' && f != '.keep')) { + fs.unlinkSync(`./public/uploads/${f}`); + } + } + for (let f of file) { if (f.endsWith('.mp4') || f.endsWith('.webm')) { // Send file name, file size in MB relative path for the file