Skip to content

Commit

Permalink
set downloadMetadata.status to 404 on unfound downloads. fixes mozill…
Browse files Browse the repository at this point in the history
…a#1501

Co-authored-by: timvisee <[email protected]>
  • Loading branch information
dannycoates and timvisee committed Oct 16, 2020
1 parent 239fba4 commit 28c48f5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
6 changes: 5 additions & 1 deletion app/ui/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,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.transfer && !state.fileInfo.requiresPassword) {
Expand Down
11 changes: 10 additions & 1 deletion server/routes/pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,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 } })
)
)
);
}
};

0 comments on commit 28c48f5

Please sign in to comment.