From 3020af632b4d78dd10d01838e2a6a54101bb78a7 Mon Sep 17 00:00:00 2001 From: Arpit Mohan Date: Tue, 25 Feb 2020 11:26:41 +0530 Subject: [PATCH] When deleting a page, also remove it from the application page cache. This fixes the bug where the application could not be published because it assumed a page existed when that page had been deleted. --- .../com/appsmith/server/services/PageServiceImpl.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/PageServiceImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/PageServiceImpl.java index 372c5deb43..f6048dd19d 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/PageServiceImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/PageServiceImpl.java @@ -95,17 +95,23 @@ public class PageServiceImpl extends BaseService i .switchIfEmpty(Mono.error(new AppsmithException(AppsmithError.NO_RESOURCE_FOUND, FieldName.PAGE_ID, id))) .flatMap(page -> { log.debug("Going to archive pageId: {} for applicationId: {}", page.getId(), page.getApplicationId()); + Mono applicationMono = applicationService.getById(page.getApplicationId()) + .flatMap(application -> { + application.getPages().removeIf(p -> p.getId().equals(page.getId())); + return applicationService.save(application); + }); Mono archivedPageMono = repository.archive(page); Mono> archivedActionsMono = actionRepository.findByPageId(page.getId()) .flatMap(action -> { log.debug("Going to archive actionId: {} for applicationId: {}", action.getId(), id); return actionRepository.archive(action); }).collectList(); - return Mono.zip(archivedPageMono, archivedActionsMono) + return Mono.zip(archivedPageMono, archivedActionsMono, applicationMono) .map(tuple -> { Page page1 = tuple.getT1(); List actions = tuple.getT2(); - log.debug("Archived pageId: {} and {} actions for applicationId: {}", page1.getId(), actions.size(), id); + Application application = tuple.getT3(); + log.debug("Archived pageId: {} and {} actions for applicationId: {}", page1.getId(), actions.size(), application.getId()); return page1; }); });