Skip to content

Commit

Permalink
fixup! Transfer shares of the transferred root node
Browse files Browse the repository at this point in the history
  • Loading branch information
juliushaertl committed Aug 31, 2020
1 parent e361e0c commit d6974b3
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions apps/files/lib/Service/OwnershipTransferService.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ public function transfer(IUser $sourceUser,
$shares = $this->collectUsersShares(
$sourceUid,
$output,
$view,
$sourcePath
);

Expand Down Expand Up @@ -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 ...");

Expand All @@ -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;
}
Expand Down

0 comments on commit d6974b3

Please sign in to comment.