diff --git a/routes/videoRoutes.js b/routes/videoRoutes.js index 03f55a6..9428b45 100644 --- a/routes/videoRoutes.js +++ b/routes/videoRoutes.js @@ -347,21 +347,12 @@ router.post('/videos/render/:video_id', async (req, res) => { console.log('Path list:', pathList); res.json({ message: 'Render process started' }); - const videoFile = await videoManager.createVideoWithList(project_id, pathList, duration); + const videoFile = await videoManager.createVideoWithList(project_id, pathList, duration, videoId); console.log('Video file:', videoFile); await videoManager.updateVideoFile(videoId, videoFile); console.log('Video rendering complete'); - - //changer status de la vidéo à 1 - const query = 'UPDATE public.videos SET status = 1 WHERE id = $1'; - db.query(query, [videoId], (err, results) => { - if (err) { - return serverError.sendError('Error updating video status:', res, err); - } - console.log('Video status updated:', results.rows[0]); - }); } catch (err) { console.error('Error during video rendering:', err); res.status(500).json({ error: 'Error during video rendering' }); diff --git a/src/video/videoManager.js b/src/video/videoManager.js index 6f4b7ce..2a5f346 100644 --- a/src/video/videoManager.js +++ b/src/video/videoManager.js @@ -27,7 +27,7 @@ async function deleteVideoProject(videoId) { return res.rows[0]; } -async function createVideoWithList(projectId, pathList, duration) { +async function createVideoWithList(projectId, pathList, duration, videoId) { const tempFile = path.join('temp.txt'); try { const workdir = path.join(PROJECTS_DIR, 'storage', `${projectId}`); @@ -89,6 +89,15 @@ async function createVideoWithList(projectId, pathList, duration) { fs.unlinkSync(tempFile); console.log('Temporary file deleted:', tempFile); } + + //changer status de la vidéo à 1 + const query = 'UPDATE public.videos SET status = 1 WHERE id = $1'; + db.query(query, [videoId], (err, results) => { + if (err) { + return serverError.sendError('Error updating video status:', res, err); + } + console.log('Video status updated:', results.rows[0]); + }); } }