Refactor la gestion des fichiers vidéo pour utiliser un chemin de vidéo par défaut en cas d'absence de fichier, améliorant ainsi la robustesse du service.

This commit is contained in:
2025-03-31 09:39:30 +02:00
parent 3849042869
commit 7942a025e8

View File

@@ -134,14 +134,13 @@ router.get('/videos/file/:video_id', (req, res) => {
return res.status(400).json({ error: 'Video not yet produced' }); return res.status(400).json({ error: 'Video not yet produced' });
} }
const videoPath = video.video_file; let videoPath = video.video_file;
// Check if the video file exists // Check if the video file exists
fs.access(videoPath, fs.constants.F_OK, (err) => { fs.access(videoPath, fs.constants.F_OK, (err) => {
if (err) { if (err) {
console.error('Video file not found:', err); console.error('Video file not found:', err);
videoPath = dbTester.getCatVideo(); videoPath = dbTester.getCatVideo();
// return res.status(404).json({ error: 'Video file not found' });
} }
const stat = fs.statSync(videoPath); const stat = fs.statSync(videoPath);