From 72c5684da93f2b90163142995facc84a27009c36 Mon Sep 17 00:00:00 2001 From: Jurgis Sakalauskas Date: Wed, 14 Dec 2022 16:03:20 +0200 Subject: [PATCH] streamer: handling errors does not happen, add workaround --- src/KodiApi/AllFiles/all-files.service.ts | 7 ++++++- src/Streamer/streamer.service.ts | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/KodiApi/AllFiles/all-files.service.ts b/src/KodiApi/AllFiles/all-files.service.ts index 6df3f3f..103fb13 100644 --- a/src/KodiApi/AllFiles/all-files.service.ts +++ b/src/KodiApi/AllFiles/all-files.service.ts @@ -138,7 +138,12 @@ export class AllFilesService { const entity = await this.fileRepository.findOne({ where: { id: id } }); 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); diff --git a/src/Streamer/streamer.service.ts b/src/Streamer/streamer.service.ts index e06e697..5a84800 100644 --- a/src/Streamer/streamer.service.ts +++ b/src/Streamer/streamer.service.ts @@ -20,7 +20,9 @@ export class StreamerService { ): Promise { const stats: Stats | false = await stat(filePath).catch(() => false); if (stats === false) { - throw new NotFoundException('file not found'); + this.sendResponse(response, 404, {}); + + return; } const requestRange = this.requestRangeService.getRangeFromHeaders(