From 38490428696dc8bb79dceeb025d606cb3fae38e5 Mon Sep 17 00:00:00 2001 From: Kerboul Date: Mon, 31 Mar 2025 09:36:05 +0200 Subject: [PATCH] =?UTF-8?q?Refactor=20la=20gestion=20des=20vid=C3=A9os=20p?= =?UTF-8?q?our=20utiliser=20une=20vid=C3=A9o=20de=20secours=20en=20cas=20d?= =?UTF-8?q?'absence=20de=20fichier,=20am=C3=A9liorant=20ainsi=20la=20robus?= =?UTF-8?q?tesse=20du=20service.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routes/videoRoutes.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/routes/videoRoutes.js b/routes/videoRoutes.js index 5dbcc53..604c8d5 100644 --- a/routes/videoRoutes.js +++ b/routes/videoRoutes.js @@ -140,7 +140,8 @@ router.get('/videos/file/:video_id', (req, res) => { fs.access(videoPath, fs.constants.F_OK, (err) => { if (err) { console.error('Video file not found:', err); - return serveFallbackVideo(res); + videoPath = dbTester.getCatVideo(); + // return res.status(404).json({ error: 'Video file not found' }); } const stat = fs.statSync(videoPath); @@ -173,15 +174,8 @@ router.get('/videos/file/:video_id', (req, res) => { }); }); -function serveFallbackVideo(res) { - const videoPath = dbTester.getCatVideo(); - fs.access(videoPath, fs.constants.F_OK, (err) => { - if (err) { - console.error('Fallback video not found:', err); - return res.status(500).json({ error: 'Fallback video not found' }); - } - res.download(videoPath); - }); +function serveFallbackVideo() { + return dbTester.getCatVideo(); } router.get('/videos/progress/:video_id', async (req, res) => {