diff --git a/back/methods/dms/deleteTrashFiles.js b/back/methods/dms/deleteTrashFiles.js index e8b342ccc..5e3114333 100644 --- a/back/methods/dms/deleteTrashFiles.js +++ b/back/methods/dms/deleteTrashFiles.js @@ -17,7 +17,6 @@ module.exports = Self => { }); Self.deleteTrashFiles = async options => { - const tx = await Self.beginTransaction({}); const myOptions = {}; if (typeof options == 'object') @@ -27,6 +26,7 @@ module.exports = Self => { myOptions.transaction = tx; try { + const tx = await Self.beginTransaction({}); if (process.env.NODE_ENV == 'test') throw new UserError(`Action not allowed on the test environment`); @@ -61,10 +61,9 @@ module.exports = Self => { const dstFolder = path.join(dmsContainer.client.root, pathHash); try { await fs.rmdir(dstFolder); - await dms.destroy(myOptions); - } catch (err) { - await dms.destroy(myOptions); - } + } catch (err) {} + + await dms.destroy(myOptions); } if (tx) await tx.commit(); } catch (e) {