diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2021-06-01 01:36:53 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-06-02 16:57:07 +0200 |
commit | 76148b27f7501bac061992136852be4303370c8d (patch) | |
tree | fc0559253e833c9252fa14ebaec5321d88bfb4e8 /server/controllers/lazy-static.ts | |
parent | 5ed25fb76e920dac364cb9ef46f14ec4bd372949 (diff) | |
download | PeerTube-76148b27f7501bac061992136852be4303370c8d.tar.gz PeerTube-76148b27f7501bac061992136852be4303370c8d.tar.zst PeerTube-76148b27f7501bac061992136852be4303370c8d.zip |
refactor API errors to standard error format
Diffstat (limited to 'server/controllers/lazy-static.ts')
-rw-r--r-- | server/controllers/lazy-static.ts | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/server/controllers/lazy-static.ts b/server/controllers/lazy-static.ts index 25d3b49b4..9f260cef0 100644 --- a/server/controllers/lazy-static.ts +++ b/server/controllers/lazy-static.ts | |||
@@ -56,10 +56,10 @@ async function getActorImage (req: express.Request, res: express.Response) { | |||
56 | } | 56 | } |
57 | 57 | ||
58 | const image = await ActorImageModel.loadByName(filename) | 58 | const image = await ActorImageModel.loadByName(filename) |
59 | if (!image) return res.sendStatus(HttpStatusCode.NOT_FOUND_404) | 59 | if (!image) return res.status(HttpStatusCode.NOT_FOUND_404).end() |
60 | 60 | ||
61 | if (image.onDisk === false) { | 61 | if (image.onDisk === false) { |
62 | if (!image.fileUrl) return res.sendStatus(HttpStatusCode.NOT_FOUND_404) | 62 | if (!image.fileUrl) return res.status(HttpStatusCode.NOT_FOUND_404).end() |
63 | 63 | ||
64 | logger.info('Lazy serve remote actor image %s.', image.fileUrl) | 64 | logger.info('Lazy serve remote actor image %s.', image.fileUrl) |
65 | 65 | ||
@@ -67,7 +67,7 @@ async function getActorImage (req: express.Request, res: express.Response) { | |||
67 | await pushActorImageProcessInQueue({ filename: image.filename, fileUrl: image.fileUrl, type: image.type }) | 67 | await pushActorImageProcessInQueue({ filename: image.filename, fileUrl: image.fileUrl, type: image.type }) |
68 | } catch (err) { | 68 | } catch (err) { |
69 | logger.warn('Cannot process remote actor image %s.', image.fileUrl, { err }) | 69 | logger.warn('Cannot process remote actor image %s.', image.fileUrl, { err }) |
70 | return res.sendStatus(HttpStatusCode.NOT_FOUND_404) | 70 | return res.status(HttpStatusCode.NOT_FOUND_404).end() |
71 | } | 71 | } |
72 | 72 | ||
73 | image.onDisk = true | 73 | image.onDisk = true |
@@ -83,21 +83,21 @@ async function getActorImage (req: express.Request, res: express.Response) { | |||
83 | 83 | ||
84 | async function getPreview (req: express.Request, res: express.Response) { | 84 | async function getPreview (req: express.Request, res: express.Response) { |
85 | const result = await VideosPreviewCache.Instance.getFilePath(req.params.filename) | 85 | const result = await VideosPreviewCache.Instance.getFilePath(req.params.filename) |
86 | if (!result) return res.sendStatus(HttpStatusCode.NOT_FOUND_404) | 86 | if (!result) return res.status(HttpStatusCode.NOT_FOUND_404).end() |
87 | 87 | ||
88 | return res.sendFile(result.path, { maxAge: STATIC_MAX_AGE.LAZY_SERVER }) | 88 | return res.sendFile(result.path, { maxAge: STATIC_MAX_AGE.LAZY_SERVER }) |
89 | } | 89 | } |
90 | 90 | ||
91 | async function getVideoCaption (req: express.Request, res: express.Response) { | 91 | async function getVideoCaption (req: express.Request, res: express.Response) { |
92 | const result = await VideosCaptionCache.Instance.getFilePath(req.params.filename) | 92 | const result = await VideosCaptionCache.Instance.getFilePath(req.params.filename) |
93 | if (!result) return res.sendStatus(HttpStatusCode.NOT_FOUND_404) | 93 | if (!result) return res.status(HttpStatusCode.NOT_FOUND_404).end() |
94 | 94 | ||
95 | return res.sendFile(result.path, { maxAge: STATIC_MAX_AGE.LAZY_SERVER }) | 95 | return res.sendFile(result.path, { maxAge: STATIC_MAX_AGE.LAZY_SERVER }) |
96 | } | 96 | } |
97 | 97 | ||
98 | async function getTorrent (req: express.Request, res: express.Response) { | 98 | async function getTorrent (req: express.Request, res: express.Response) { |
99 | const result = await VideosTorrentCache.Instance.getFilePath(req.params.filename) | 99 | const result = await VideosTorrentCache.Instance.getFilePath(req.params.filename) |
100 | if (!result) return res.sendStatus(HttpStatusCode.NOT_FOUND_404) | 100 | if (!result) return res.status(HttpStatusCode.NOT_FOUND_404).end() |
101 | 101 | ||
102 | // Torrents still use the old naming convention (video uuid + .torrent) | 102 | // Torrents still use the old naming convention (video uuid + .torrent) |
103 | return res.sendFile(result.path, { maxAge: STATIC_MAX_AGE.SERVER }) | 103 | return res.sendFile(result.path, { maxAge: STATIC_MAX_AGE.SERVER }) |