diff --git a/apps/files/lib/Service/OwnershipTransferService.php b/apps/files/lib/Service/OwnershipTransferService.php index add565c3ffe02..8ca22dfd0db9a 100644 --- a/apps/files/lib/Service/OwnershipTransferService.php +++ b/apps/files/lib/Service/OwnershipTransferService.php @@ -156,6 +156,7 @@ public function transfer(IUser $sourceUser, $shares = $this->collectUsersShares( $sourceUid, $output, + $view, $sourcePath ); @@ -244,6 +245,7 @@ function (FileInfo $fileInfo) use ($progress) { private function collectUsersShares(string $sourceUid, OutputInterface $output, + View $view, ?string $path = null): array { $output->writeln("Collecting all share information for files and folders of $sourceUid ..."); @@ -258,10 +260,17 @@ private function collectUsersShares(string $sourceUid, break; } if ($path !== null) { - $sharePage = array_filter($sharePage, function (IShare $share) use ($path) { + $sharePage = array_filter($sharePage, function (IShare $share) use ($view, $path) { try { - $node = $share->getNode(); - return \OC\Files\Filesystem::normalizePath($path) === $node->getPath(); + $relativePath = $view->getPath($share->getNodeId()); + $singleFileTranfer = $view->is_file($path); + if ($singleFileTranfer) { + return $relativePath === $path; + } + + return mb_strpos( + Filesystem::normalizePath($relativePath . '/', false), + Filesystem::normalizePath($path . '/', false)) === 0; } catch (\Exception $e) { return false; }