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:
@@ -134,14 +134,13 @@ router.get('/videos/file/:video_id', (req, res) => {
|
||||
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
|
||||
fs.access(videoPath, fs.constants.F_OK, (err) => {
|
||||
if (err) {
|
||||
console.error('Video file not found:', err);
|
||||
videoPath = dbTester.getCatVideo();
|
||||
// return res.status(404).json({ error: 'Video file not found' });
|
||||
}
|
||||
|
||||
const stat = fs.statSync(videoPath);
|
||||
|
||||
Reference in New Issue
Block a user