mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
core: FSDownload: capture invalid path error
This commit is contained in:
1 parent
9672436151
commit
4930220fca
1 file changed
+8
-3
@@ -96,9 +96,14 @@ export class FSDownloadHandler extends Handler {
|
||||
target,
|
||||
size: file?.size || 0,
|
||||
});
|
||||
this.response.redirect = await storage.signDownloadLink(
|
||||
target, noDisposition ? undefined : filename, false, 'user',
|
||||
);
|
||||
try {
|
||||
this.response.redirect = await storage.signDownloadLink(
|
||||
target, noDisposition ? undefined : filename, false, 'user',
|
||||
);
|
||||
} catch (e) {
|
||||
if (e.message.includes('Invalid path')) throw new NotFoundError(filename);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user