From aa6347723a84cb55a6da9dfd522508f335fc12c3 Mon Sep 17 00:00:00 2001 From: Kerboul Date: Wed, 15 Jan 2025 08:44:33 +0100 Subject: [PATCH] =?UTF-8?q?Remplace=20la=20suppression=20du=20r=C3=A9perto?= =?UTF-8?q?ire=20de=20projet=20par=20un=20appel=20=C3=A0=20la=20fonction?= =?UTF-8?q?=20deleteProjectDirectory=20dans=20la=20route=20DELETE=20/proje?= =?UTF-8?q?cts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routes/api.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/routes/api.js b/routes/api.js index 8586602..5e65bc5 100644 --- a/routes/api.js +++ b/routes/api.js @@ -235,7 +235,6 @@ router.post('/projects', async (req, res) => { */ router.delete('/projects/:id', async (req, res) => { const projectId = req.params.id; - const projectDir = path.join(__dirname, `../storage/${projectId}`); try { const result = await db.query('DELETE FROM public.projects WHERE id = $1 RETURNING id', [projectId]); @@ -243,7 +242,7 @@ router.delete('/projects/:id', async (req, res) => { return res.status(404).json({ error: 'No project found with this ID' }); } - fs.rmdirSync(projectDir, { recursive: true }); + fileUtils.deleteProjectDirectory(projectId); res.status(200).json({ message: 'Project deleted successfully', id: projectId }); } catch (error) { console.error('Error deleting project:', error);