Skip to content

Commit 4cd26d4

Browse files
authored
Merge pull request #31203 from nextcloud/backport/31097/stable22
[stable22] Fix path handling when transferring incoming shares
2 parents cde0a35 + 02aebdc commit 4cd26d4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

apps/files/lib/Service/OwnershipTransferService.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,13 +444,17 @@ private function transferIncomingShares(string $sourceUid,
444444
$output->writeln("Restoring incoming shares ...");
445445
$progress = new ProgressBar($output, count($sourceShares));
446446
$prefix = "$destinationUid/files";
447+
$finalShareTarget = '';
447448
if (substr($finalTarget, 0, strlen($prefix)) === $prefix) {
448449
$finalShareTarget = substr($finalTarget, strlen($prefix));
449450
}
450451
foreach ($sourceShares as $share) {
451452
try {
452453
// Only restore if share is in given path.
453-
$pathToCheck = '/' . trim($path) . '/';
454+
$pathToCheck = '/';
455+
if (trim($path, '/') !== '') {
456+
$pathToCheck = '/' . trim($path) . '/';
457+
}
454458
if (substr($share->getTarget(), 0, strlen($pathToCheck)) !== $pathToCheck) {
455459
continue;
456460
}

0 commit comments

Comments
 (0)