1
0

Attachment does not need to exist to be deleted

This commit is contained in:
Richard Dern 2024-05-03 16:15:22 +02:00
parent 0ac87d1b01
commit edb14d5ad7

View File

@ -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),