aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2024-12-10 18:23:02 +0100
committerGit'Fellow <12234510+solracsf@users.noreply.github.com>2025-03-20 10:04:18 +0100
commit67d16684c769d6183285efe69e41426b8c8f0380 (patch)
tree0d498ed002ca6dd5fd226f7a7ef6683a6e537ecb
parent10376ebd739b33841186730de4c2f34ed45203a6 (diff)
downloadnextcloud-server-backport/49761/stable30.tar.gz
nextcloud-server-backport/49761/stable30.zip
fix: skip transfering shares that we can't findbackport/49761/stable30
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 6ce15098d24..0ada5ddb9c5 100644
--- a/apps/files/lib/Service/OwnershipTransferService.php
+++ b/apps/files/lib/Service/OwnershipTransferService.php
@@ -21,6 +21,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\L10N\IFactory;
@@ -340,10 +341,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,
@@ -455,7 +465,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));
@@ -467,7 +477,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>');
@@ -547,7 +557,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>');