From 246e2c8db03f01e01e4cabf3e2c56000611d3daf Mon Sep 17 00:00:00 2001 From: Danny Coates Date: Fri, 31 Jul 2020 09:36:03 -0700 Subject: [PATCH] set downloadMetadata.status to 404 on unfound downloads. fixes #1501 --- app/ui/download.js | 6 +++++- server/routes/pages.js | 11 ++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/ui/download.js b/app/ui/download.js index cace912c..8abaa1f7 100644 --- a/app/ui/download.js +++ b/app/ui/download.js @@ -85,9 +85,13 @@ module.exports = function(state, emit) { let content = ''; if (!state.fileInfo) { state.fileInfo = createFileInfo(state); - if (!state.fileInfo.nonce) { + if (downloadMetadata.status === 404) { return notFound(state); } + if (!state.fileInfo.nonce) { + // coming from something like the browser back button + return location.reload(); + } } if (state.fileInfo.dead) { diff --git a/server/routes/pages.js b/server/routes/pages.js index c1de6529..5b1ba58d 100644 --- a/server/routes/pages.js +++ b/server/routes/pages.js @@ -59,6 +59,15 @@ module.exports = { notfound: async function(req, res) { const appState = await state(req); - res.status(404).send(stripEvents(routes().toString('/404', appState))); + res + .status(404) + .send( + stripEvents( + routes().toString( + '/404', + Object.assign(appState, { downloadMetadata: { status: 404 } }) + ) + ) + ); } };