From bfdf11d678ae7e5c57db22fe53a86278324f3dcf Mon Sep 17 00:00:00 2001
From: Andrei Cioromila <andrei.cioromila@thinslices.com>
Date: Fri, 26 Oct 2018 12:03:28 +0300
Subject: [PATCH] feature(components): delete files only when they have been
 assigned on the manuscript

---
 .../src/routes/collections/delete.js                          | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/packages/component-manuscript-manager/src/routes/collections/delete.js b/packages/component-manuscript-manager/src/routes/collections/delete.js
index b3e44632f..d207fd469 100644
--- a/packages/component-manuscript-manager/src/routes/collections/delete.js
+++ b/packages/component-manuscript-manager/src/routes/collections/delete.js
@@ -64,7 +64,7 @@ module.exports = models => async (req, res) => {
       fragmentId,
     ).map(file => file.id)
 
-    if (fileKeys.length !== 0) {
+    if (fileKeys.length > 1) {
       await deleteFilesS3({ fileKeys, s3Config })
     }
 
@@ -72,7 +72,7 @@ module.exports = models => async (req, res) => {
 
     await collection.delete()
 
-    return res.status(200).json()
+    return res.status(204).send()
   } catch (e) {
     const notFoundError = await services.handleNotFoundError(e, 'Item')
     return res.status(notFoundError.status).json({
-- 
GitLab