From 75eb5c4eda27e0867a4409f8305fe022d2b37437 Mon Sep 17 00:00:00 2001 From: daniel-j Date: Sun, 21 Jul 2024 15:18:22 +0200 Subject: [PATCH] quickfix for cached html --- index.js | 17 +++++++++++++++++ static/download.html | 3 --- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 8a3cbfc..cba7f28 100644 --- a/index.js +++ b/index.js @@ -164,6 +164,23 @@ router.post('/generate', async ctx => { ctx.body = key }) +router.get('/download/:key', async ctx => { + const key = ctx.cookies.get('key') + if (!key) { + await next() + return + } + + const info = ctx.keys.get(key) + + if (!info || !info.file) { + await next() + return + } + + ctx.redirect('/' + encodeURIComponent(info.file.name)); +}) + async function downloadFile (ctx, next) { const key = ctx.cookies.get('key') if (!key) { diff --git a/static/download.html b/static/download.html index cd989e1..0278643 100644 --- a/static/download.html +++ b/static/download.html @@ -78,9 +78,6 @@ function pollFile () { downloads.style.display = 'none' } var urls = data.urls && data.urls.length > 0 ? data.urls : null - if (data.file || urls) { - } else { - } if (data.file) { downloads.style.display = 'block' downloadlink.textContent = data.file.name