aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2024-12-10 18:23:02 +0100
committerDaniel Kesselberg <mail@danielkesselberg.de>2025-03-31 16:28:25 +0200
commitd58d2b9035f1384b4be23c0951ddeb0478411324 (patch)
tree06dce27c31d3fb7646fc1e59e80f5b334412ee10
parent95c22db4d505d035cbe77773d9b6bc4a98a52eca (diff)
downloadnextcloud-server-backport/49761/stable29.tar.gz
nextcloud-server-backport/49761/stable29.zip
fix: skip transfering shares that we can't findbackport/49761/stable29
Signed-off-by: Robin Appelman <robin@icewind.nl> Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
-rw-r--r--apps/files/lib/Service/OwnershipTransferService.php24
1 files changed, 17 insertions, 7 deletions
diff --git a/apps/files/lib/Service/OwnershipTransferService.php b/apps/files/lib/Service/OwnershipTransferService.php
index fd462a3f7db..f736013c296 100644
--- a/apps/files/lib/Service/OwnershipTransferService.php
+++ b/apps/files/lib/Service/OwnershipTransferService.php
@@ -45,6 +45,7 @@ use OCP\Files\IHomeStorage;
use OCP\Files\InvalidPathException;
use OCP\Files\IRootFolder;
use OCP\Files\Mount\IMountManager;
+use OCP\Files\NotFoundException;
use OCP\IUser;
use OCP\IUserManager;
use OCP\Share\IManager as IShareManager;
@@ -365,10 +366,19 @@ class OwnershipTransferService {
$progress->finish();
$output->writeln('');
- return array_map(fn (IShare $share) => [
- 'share' => $share,
- 'suffix' => substr(Filesystem::normalizePath($view->getPath($share->getNodeId())), strlen($normalizedPath)),
- ], $shares);
+ return array_values(array_filter(array_map(function (IShare $share) use ($view, $normalizedPath, $output, $sourceUid) {
+ try {
+ $nodePath = $view->getPath($share->getNodeId());
+ } catch (NotFoundException $e) {
+ $output->writeln("<error>Failed to find path for shared file {$share->getNodeId()} for user $sourceUid, skipping</error>");
+ return null;
+ }
+
+ return [
+ 'share' => $share,
+ 'suffix' => substr(Filesystem::normalizePath($nodePath), strlen($normalizedPath)),
+ ];
+ }, $shares)));
}
private function collectIncomingShares(string $sourceUid,
@@ -480,7 +490,7 @@ class OwnershipTransferService {
// Normally the ID is preserved,
// but for transferes between different storages the ID might change
$newNodeId = $share->getNode()->getId();
- } catch (\OCP\Files\NotFoundException) {
+ } catch (NotFoundException) {
// ID has changed due to transfer between different storages
// Try to get the new ID from the target path and suffix of the share
$node = $this->rootFolder->get(Filesystem::normalizePath($targetLocation . '/' . $suffix));
@@ -492,7 +502,7 @@ class OwnershipTransferService {
$this->shareManager->updateShare($share);
}
}
- } catch (\OCP\Files\NotFoundException $e) {
+ } catch (NotFoundException $e) {
$output->writeln('<error>Share with id ' . $share->getId() . ' points at deleted file, skipping</error>');
} catch (\Throwable $e) {
$output->writeln('<error>Could not restore share with id ' . $share->getId() . ':' . $e->getMessage() . ' : ' . $e->getTraceAsString() . '</error>');
@@ -572,7 +582,7 @@ class OwnershipTransferService {
$this->shareManager->moveShare($share, $destinationUid);
continue;
}
- } catch (\OCP\Files\NotFoundException $e) {
+ } catch (NotFoundException $e) {
$output->writeln('<error>Share with id ' . $share->getId() . ' points at deleted file, skipping</error>');
} catch (\Throwable $e) {
$output->writeln('<error>Could not restore share with id ' . $share->getId() . ':' . $e->getTraceAsString() . '</error>');