set downloadMetadata.status to 404 on unfound downloads. fixes #1501
Co-authored-by: timvisee <tim@visee.me>
This commit is contained in:
parent
239fba452a
commit
28c48f51d1
|
@ -55,9 +55,13 @@ module.exports = function(state, emit) {
|
||||||
let content = '';
|
let content = '';
|
||||||
if (!state.fileInfo) {
|
if (!state.fileInfo) {
|
||||||
state.fileInfo = createFileInfo(state);
|
state.fileInfo = createFileInfo(state);
|
||||||
if (!state.fileInfo.nonce) {
|
if (downloadMetadata.status === 404) {
|
||||||
return notFound(state);
|
return notFound(state);
|
||||||
}
|
}
|
||||||
|
if (!state.fileInfo.nonce) {
|
||||||
|
// coming from something like the browser back button
|
||||||
|
return location.reload();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!state.transfer && !state.fileInfo.requiresPassword) {
|
if (!state.transfer && !state.fileInfo.requiresPassword) {
|
||||||
|
|
|
@ -56,6 +56,15 @@ module.exports = {
|
||||||
|
|
||||||
notfound: async function(req, res) {
|
notfound: async function(req, res) {
|
||||||
const appState = await state(req);
|
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 } })
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue