From a2fcb4debdb5038c1b3445c222a5fc418277d7bc Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Fri, 26 Nov 2021 11:08:10 +0100 Subject: fix moveAttachments in shared context (single file and directory share) Signed-off-by: Julien Veyssier --- lib/Service/ImageService.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/Service/ImageService.php b/lib/Service/ImageService.php index 5c6db0259..5c6941def 100644 --- a/lib/Service/ImageService.php +++ b/lib/Service/ImageService.php @@ -635,9 +635,12 @@ class ImageService { public function moveAttachments(File $source, File $target): void { // if the parent directory has changed if ($source->getParent()->getPath() !== $target->getParent()->getPath()) { - // if there is an attachment dir for this file $sourceAttachmentDir = $this->getAttachmentDirectoryForFile($source); - if ($sourceAttachmentDir !== null) { + // if there is an attachment dir for this file + // and it is in the same directory as the source file + if ($sourceAttachmentDir !== null + && $source->getParent()->getId() === $sourceAttachmentDir->getParent()->getId() + ) { $sourceAttachmentDir->move($target->getParent()->getPath() . '/' . $sourceAttachmentDir->getName()); } } -- cgit v1.2.3