Skip to content

Commit

Permalink
fix: /metainfo response code (#740)
Browse files Browse the repository at this point in the history
  • Loading branch information
trim21 committed May 3, 2024
1 parent e0cd98f commit 875a575
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions server/routes/api/torrents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,15 @@ router.get<{hashes: string}>(
await fs.promises.access(path.join(sessionDirectory, torrentFileName), fs.constants.R_OK),
),
);
} catch {
return res.status(404).json({code: 404, message: 'Failed to access torrent files.'});
} catch (e) {
const err = e as NodeJS.ErrnoException;
if (err.code === 'ENOENT') {
return res.status(404).json({code: err.code, message: err.message});
}
return res.status(500).json({
code: err.code,
message: `Failed to access torrent files: ${e}`,
});
}

if (hashes.length < 2) {
Expand Down

0 comments on commit 875a575

Please sign in to comment.