From d7841b3c47b128e8202db3c493cfe4bfc1130cec Mon Sep 17 00:00:00 2001 From: Matthieu Bessat Date: Mon, 10 Aug 2020 18:05:16 +0200 Subject: [PATCH] fix(Delegate): thumbnail and cover removal, logic issue --- src/controllers/DelegateController.ts | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/controllers/DelegateController.ts b/src/controllers/DelegateController.ts index b0c2260..9978db6 100644 --- a/src/controllers/DelegateController.ts +++ b/src/controllers/DelegateController.ts @@ -252,9 +252,14 @@ export default class DelegateController { let proposedVersion: any = res.locals.organization.proposedVersion const publishedVersion: any = res.locals.organization.publishedVersion if ( - Utils.isStrUsable(proposedVersion, 'thumbnail.location') && - Utils.isStrUsable(publishedVersion, 'thumbnail.location') && - publishedVersion.thumbnail.location !== proposedVersion.thumbnail.location + Utils.isStrUsable(proposedVersion, 'thumbnail.location') && + ( + ( + Utils.isStrUsable(publishedVersion, 'thumbnail.location') && + publishedVersion.thumbnail.location !== proposedVersion.thumbnail.location + ) || + !Utils.isStrUsable(publishedVersion, 'thumbnail.location') + ) ) { MediaService.delete(proposedVersion.thumbnail.key, 'thumbnailUpdated') } @@ -280,9 +285,14 @@ export default class DelegateController { let proposedVersion: any = res.locals.organization.proposedVersion const publishedVersion: any = res.locals.organization.publishedVersion if ( - Utils.isStrUsable(proposedVersion, 'cover.location') && - Utils.isStrUsable(publishedVersion, 'cover.location') && - publishedVersion.cover.location !== proposedVersion.cover.location + Utils.isStrUsable(proposedVersion, 'cover.location') && + ( + ( + Utils.isStrUsable(publishedVersion, 'cover.location') && + publishedVersion.cover.location !== proposedVersion.cover.location + ) || + !Utils.isStrUsable(publishedVersion, 'cover.location') + ) ) { MediaService.delete(proposedVersion.cover.key, 'coverUpdated') }