diff --git a/apps/files_versions/lib/Listener/VersionStorageMoveListener.php b/apps/files_versions/lib/Listener/VersionStorageMoveListener.php index 0f7dad29fe250..d0a0bcf4a9236 100644 --- a/apps/files_versions/lib/Listener/VersionStorageMoveListener.php +++ b/apps/files_versions/lib/Listener/VersionStorageMoveListener.php @@ -11,6 +11,7 @@ use Exception; use OC\Files\Node\NonExistingFile; +use OC\Files\Node\NonExistingFolder; use OCA\Files_Versions\Versions\IVersionBackend; use OCA\Files_Versions\Versions\IVersionManager; use OCA\Files_Versions\Versions\IVersionsImporterBackend; @@ -130,7 +131,7 @@ private function handleMoveOrCopy(Event $event, IUser $user, File $source, File } private function getNodeStorage(Node $node): IStorage { - if ($node instanceof NonExistingFile) { + if ($node instanceof NonExistingFile || $node instanceof NonExistingFolder) { return $node->getParent()->getStorage(); } else { return $node->getStorage(); diff --git a/lib/private/Files/Node/HookConnector.php b/lib/private/Files/Node/HookConnector.php index 423eea258ed6c..1149951174cbf 100644 --- a/lib/private/Files/Node/HookConnector.php +++ b/lib/private/Files/Node/HookConnector.php @@ -171,7 +171,7 @@ public function postRename($arguments) { public function copy($arguments) { $source = $this->getNodeForPath($arguments['oldpath']); - $target = $this->getNodeForPath($arguments['newpath']); + $target = $this->getNodeForPath($arguments['newpath'], $source instanceof Folder); $this->root->emit('\OC\Files', 'preCopy', [$source, $target]); $this->dispatcher->dispatch('\OCP\Files::preCopy', new GenericEvent([$source, $target])); @@ -203,7 +203,7 @@ public function read($arguments) { $this->dispatcher->dispatchTyped($event); } - private function getNodeForPath(string $path): Node { + private function getNodeForPath(string $path, bool $isDir = false): Node { $info = Filesystem::getView()->getFileInfo($path); if (!$info) { $fullPath = Filesystem::getView()->getAbsolutePath($path); @@ -212,7 +212,7 @@ private function getNodeForPath(string $path): Node { } else { $info = null; } - if (Filesystem::is_dir($path)) { + if ($isDir || Filesystem::is_dir($path)) { return new NonExistingFolder($this->root, $this->view, $fullPath, $info); } else { return new NonExistingFile($this->root, $this->view, $fullPath, $info);