Skip to content

Commit 25b9701

Browse files
committed
fixup! Transfer shares of the transferred root node
1 parent 033b95a commit 25b9701

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
@@ -158,6 +158,7 @@ public function transfer(IUser $sourceUser,
158158
$shares = $this->collectUsersShares(
159159
$sourceUid,
160160
$output,
161+
$view,
161162
$sourcePath
162163
);
163164

@@ -246,6 +247,7 @@ function (FileInfo $fileInfo) use ($progress) {
246247

247248
private function collectUsersShares(string $sourceUid,
248249
OutputInterface $output,
250+
View $view,
249251
?string $path = null): array {
250252
$output->writeln("Collecting all share information for files and folders of $sourceUid ...");
251253

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

0 commit comments

Comments
 (0)