From 6247615e3dec70d534d08c5a994aa82f465f4861 Mon Sep 17 00:00:00 2001 From: "jill \"oatmealine\" monoids" Date: Tue, 19 Oct 2021 21:18:50 +0000 Subject: [PATCH] fix some potentially fatal issues --- src/index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 7e946f8..9f6ec27 100644 --- a/src/index.js +++ b/src/index.js @@ -82,13 +82,18 @@ app.ws('/api/album', async (ws, req) => { send(key, data) { if (data.downloaded) { ws.send(JSON.stringify({key: 'download', data: data.downloadPath.replace(process.cwd(), '')})); + console.log('downloaded ' + data.downloadPath + ', deleting in 1hr') setTimeout(() => { - fs.unlinkSync(data.downloadPath); + try { + fs.unlinkSync(data.downloadPath); + } catch(err) { + console.log('tried to delete ' + data.downloadPath + ', but failed? its likely already gone') + } }, 1000 * 60 * 60 /* 1 hour */); } ws.send(JSON.stringify({key, data})); - console.log(`[${key}] ${inspect(data)}`); + //console.log(`[${key}] ${inspect(data)}`); } };