Skip to content

Commit d6974b3

Browse files
committed
fixup! Transfer shares of the transferred root node
1 parent e361e0c commit d6974b3

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

apps/files/lib/Service/OwnershipTransferService.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ public function transfer(IUser $sourceUser,
156156
$shares = $this->collectUsersShares(
157157
$sourceUid,
158158
$output,
159+
$view,
159160
$sourcePath
160161
);
161162

@@ -244,6 +245,7 @@ function (FileInfo $fileInfo) use ($progress) {
244245

245246
private function collectUsersShares(string $sourceUid,
246247
OutputInterface $output,
248+
View $view,
247249
?string $path = null): array {
248250
$output->writeln("Collecting all share information for files and folders of $sourceUid ...");
249251

@@ -258,10 +260,17 @@ private function collectUsersShares(string $sourceUid,
258260
break;
259261
}
260262
if ($path !== null) {
261-
$sharePage = array_filter($sharePage, function (IShare $share) use ($path) {
263+
$sharePage = array_filter($sharePage, function (IShare $share) use ($view, $path) {
262264
try {
263-
$node = $share->getNode();
264-
return \OC\Files\Filesystem::normalizePath($path) === $node->getPath();
265+
$relativePath = $view->getPath($share->getNodeId());
266+
$singleFileTranfer = $view->is_file($path);
267+
if ($singleFileTranfer) {
268+
return $relativePath === $path;
269+
}
270+
271+
return mb_strpos(
272+
Filesystem::normalizePath($relativePath . '/', false),
273+
Filesystem::normalizePath($path . '/', false)) === 0;
265274
} catch (\Exception $e) {
266275
return false;
267276
}

0 commit comments

Comments
 (0)