From 3fd0464a7fdc36af87cc54b30b133c48cd912e85 Mon Sep 17 00:00:00 2001 From: daniel-j Date: Wed, 4 Mar 2020 15:31:36 +0100 Subject: [PATCH] fix potential crash, don't throw --- index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 5e6972e..4d88df4 100644 --- a/index.js +++ b/index.js @@ -32,9 +32,11 @@ function removeKey (key) { if (info) { clearTimeout(app.context.keys.get(key).timer) if (info.file) { + console.log('Deleting file', info.file.path) fs.unlink(info.file.path, (err) => { if (err) console.error(err) }) + info.file = null } app.context.keys.delete(key) } else { @@ -132,7 +134,8 @@ router.get('/download/:key', async ctx => { return } if (info.agent !== ctx.get('user-agent')) { - throw new Error("User Agent doesnt match: " + info.agent + " VS " + ctx.get('user-agent')) + console.error("User Agent doesnt match: " + info.agent + " VS " + ctx.get('user-agent')) + return } expireKey(key) console.log('Sending file!')