Remplace la suppression du répertoire de projet par un appel à la fonction deleteProjectDirectory dans la route DELETE /projects
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user