streamer: handling errors does not happen, add workaround

This commit is contained in:
Jurgis Sakalauskas
2022-12-14 16:03:20 +02:00
parent df6bf9465f
commit 72c5684da9
2 changed files with 9 additions and 2 deletions
+6 -1
View File
@@ -138,7 +138,12 @@ export class AllFilesService {
const entity = await this.fileRepository.findOne({ where: { id: id } }); const entity = await this.fileRepository.findOne({ where: { id: id } });
if (entity === null) { if (entity === null) {
throw new NotFoundException('entity not found id: ' + fileId); response
.status(404)
.send('entity not found id: ' + fileId)
.end();
return;
} }
this.streamerFacade.streamFile(request, response, entity.path); this.streamerFacade.streamFile(request, response, entity.path);
+3 -1
View File
@@ -20,7 +20,9 @@ export class StreamerService {
): Promise<void> { ): Promise<void> {
const stats: Stats | false = await stat(filePath).catch(() => false); const stats: Stats | false = await stat(filePath).catch(() => false);
if (stats === false) { if (stats === false) {
throw new NotFoundException('file not found'); this.sendResponse(response, 404, {});
return;
} }
const requestRange = this.requestRangeService.getRangeFromHeaders( const requestRange = this.requestRangeService.getRangeFromHeaders(