From edb14d5ad75b75174a8640199fe0653478610e9c Mon Sep 17 00:00:00 2001 From: Richard Dern Date: Fri, 3 May 2024 16:15:22 +0200 Subject: [PATCH] Attachment does not need to exist to be deleted --- app/Classes/AttachmentsManager.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/app/Classes/AttachmentsManager.php b/app/Classes/AttachmentsManager.php index 4570faa..43f0329 100644 --- a/app/Classes/AttachmentsManager.php +++ b/app/Classes/AttachmentsManager.php @@ -209,14 +209,9 @@ public function getComponentByRef(string $ref, ?string $filter, ?array $options */ public function deleteAttachment(string $ref) { - $path = $this->getAttachmentFullPath($ref); - $parent = dirname($path); + $path = sprintf('%s%s/%s/%s', $this->bundle->getDataDir(), $this->attachmentsDir, $this->kind, $ref); - $this->disk->delete($path); - - if (empty($this->disk->listContents($parent, true))) { - $this->disk->delete($parent); - } + $this->disk->deleteDirectory($path); $this->manager->remove([ sprintf('files.%s', $ref),