mirror of
https://github.com/immich-app/immich
synced 2026-08-15 13:03:57 +00:00
fix: error handling (#28843)
This commit is contained in:
parent
b3d49045de
commit
9043bc8435
1 changed files with 5 additions and 5 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { HttpException, StreamableFile } from '@nestjs/common';
|
||||
import { HttpException, NotFoundException, StreamableFile } from '@nestjs/common';
|
||||
import { NextFunction, Response } from 'express';
|
||||
import { access, constants } from 'node:fs/promises';
|
||||
import { basename, extname } from 'node:path';
|
||||
|
|
@ -52,6 +52,9 @@ export const sendFile = async (
|
|||
|
||||
try {
|
||||
const file = await handler();
|
||||
|
||||
await access(file.path, constants.R_OK);
|
||||
|
||||
const cacheControlHeader = cacheControlHeaders[file.cacheControl];
|
||||
if (cacheControlHeader) {
|
||||
// set the header to Cache-Control
|
||||
|
|
@ -63,8 +66,6 @@ export const sendFile = async (
|
|||
res.header('Content-Disposition', `inline; filename*=UTF-8''${encodeURIComponent(file.fileName)}`);
|
||||
}
|
||||
|
||||
await access(file.path, constants.R_OK);
|
||||
|
||||
return await _sendFile(file.path, { dotfiles: 'allow' });
|
||||
} catch (error: Error | any) {
|
||||
// ignore client-closed connection
|
||||
|
|
@ -77,8 +78,7 @@ export const sendFile = async (
|
|||
logger.error(`Unable to send file: ${error}`, error.stack);
|
||||
}
|
||||
|
||||
res.header('Cache-Control', 'none');
|
||||
next(error);
|
||||
next(new NotFoundException());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue