Do not delete an file if there is an other attachment remaining after deletion.

Fixes issue #71.
This commit is contained in:
Jan Böhmer 2020-06-13 21:55:20 +02:00
parent a846f373c0
commit 167e46fea4

View file

@ -131,7 +131,9 @@ class AttachmentDeleteListener
$file = $this->attachmentHelper->attachmentToFile($attachment);
//Only delete if the attachment has a valid file.
if (null !== $file) {
$this->attachmentReverseSearch->deleteIfNotUsed($file);
/* The original file has already been removed, so we have to decrease the threshold to zero,
as any remaining attachment depends on this attachment, and we must not delete this file! */
$this->attachmentReverseSearch->deleteIfNotUsed($file, 0);
}
}
}