Skip to content

Commit

Permalink
Fix attached document deletion (v5) (#1740)
Browse files Browse the repository at this point in the history
Backport of #1737 into v5.
  • Loading branch information
johnnyomair authored Feb 22, 2024
1 parent ea12945 commit 3a55904
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/clever-guests-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@comet/cms-api": patch
---

Fix attached document deletion when deleting a page tree node
3 changes: 2 additions & 1 deletion packages/api/cms-api/src/page-tree/page-tree.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,8 @@ export class PageTreeService {
if (attachedDocument.id) {
try {
const repository = this.em.getRepository(attachedDocument.type);
await repository.removeAndFlush(attachedDocument);
const document = await repository.findOneOrFail(attachedDocument.documentId);
await repository.removeAndFlush(document);
await this.attachedDocumentsRepository.removeAndFlush(attachedDocument);
} catch {
throw new Error(`documentType ${attachedDocument.type} and documentId ${attachedDocument.id} cannot resolve`);
Expand Down

0 comments on commit 3a55904

Please sign in to comment.