set downloadMetadata.status to 404 on unfound downloads. fixes #1501

This commit is contained in:
Danny Coates 2020-07-31 09:36:03 -07:00
parent fbc4107262
commit 246e2c8db0
No known key found for this signature in database
GPG key ID: 4C442633C62E00CB
2 changed files with 15 additions and 2 deletions

View file

@ -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) {

View file

@ -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 } })
)
)
);
}
};