From 3a6d4ae3aa4c76acec286191205159671cd84f29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Mon, 7 Oct 2024 15:35:47 +0200 Subject: [PATCH 1/3] feat(transfer-ownership): Improve verbose output of command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Makes debbuging way easier Signed-off-by: Côme Chilliet --- apps/files/lib/Service/OwnershipTransferService.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/files/lib/Service/OwnershipTransferService.php b/apps/files/lib/Service/OwnershipTransferService.php index 71c3731b66b..c725bf6a4a6 100644 --- a/apps/files/lib/Service/OwnershipTransferService.php +++ b/apps/files/lib/Service/OwnershipTransferService.php @@ -420,6 +420,7 @@ class OwnershipTransferService { foreach ($shares as ['share' => $share, 'suffix' => $suffix]) { try { + $output->writeln('Transfering share ' . $share->getId() . ' of type ' . $share->getShareType(), OutputInterface::VERBOSITY_VERBOSE); if ($share->getShareType() === IShare::TYPE_USER && $share->getSharedWith() === $destinationUid) { // Unmount the shares before deleting, so we don't try to get the storage later on. @@ -457,6 +458,7 @@ class OwnershipTransferService { // Try to get the new ID from the target path and suffix of the share $node = $rootFolder->get(Filesystem::normalizePath($targetLocation . '/' . $suffix)); $newNodeId = $node->getId(); + $output->writeln('Had to change node id to ' . $newNodeId, OutputInterface::VERBOSITY_VERY_VERBOSE); } $share->setNodeId($newNodeId); From 54905c39238c38dba04ba77d85b2349e76c0abd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Mon, 7 Oct 2024 15:36:53 +0200 Subject: [PATCH 2/3] fix(sharebymail): Fix share update when node id changed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes transfering an email share from a user to another one when using objectstore as primary storage. Signed-off-by: Côme Chilliet --- apps/sharebymail/lib/ShareByMailProvider.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/sharebymail/lib/ShareByMailProvider.php b/apps/sharebymail/lib/ShareByMailProvider.php index b21f6440c64..556c7fafd6f 100644 --- a/apps/sharebymail/lib/ShareByMailProvider.php +++ b/apps/sharebymail/lib/ShareByMailProvider.php @@ -738,11 +738,14 @@ class ShareByMailProvider extends DefaultShareProvider implements IShareProvider $shareAttributes = $this->formatShareAttributes($share->getAttributes()); /* - * We allow updating the permissions and password of mail shares + * We allow updating mail shares */ $qb = $this->dbConnection->getQueryBuilder(); $qb->update('share') ->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId()))) + ->set('item_source', $qb->createNamedParameter($share->getNode()->getId())) + ->set('file_source', $qb->createNamedParameter($share->getNode()->getId())) + ->set('share_with', $qb->createNamedParameter($share->getSharedWith())) ->set('permissions', $qb->createNamedParameter($share->getPermissions())) ->set('uid_owner', $qb->createNamedParameter($share->getShareOwner())) ->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy())) From 5b1cbaf583877a07fc3105c89f69ec64d5d89785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Tue, 8 Oct 2024 16:53:51 +0200 Subject: [PATCH 3/3] fix(tests): Fix sharebymail tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- apps/sharebymail/lib/ShareByMailProvider.php | 4 ++-- apps/sharebymail/tests/ShareByMailProviderTest.php | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/sharebymail/lib/ShareByMailProvider.php b/apps/sharebymail/lib/ShareByMailProvider.php index 556c7fafd6f..fd844128827 100644 --- a/apps/sharebymail/lib/ShareByMailProvider.php +++ b/apps/sharebymail/lib/ShareByMailProvider.php @@ -743,8 +743,8 @@ class ShareByMailProvider extends DefaultShareProvider implements IShareProvider $qb = $this->dbConnection->getQueryBuilder(); $qb->update('share') ->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId()))) - ->set('item_source', $qb->createNamedParameter($share->getNode()->getId())) - ->set('file_source', $qb->createNamedParameter($share->getNode()->getId())) + ->set('item_source', $qb->createNamedParameter($share->getNodeId())) + ->set('file_source', $qb->createNamedParameter($share->getNodeId())) ->set('share_with', $qb->createNamedParameter($share->getSharedWith())) ->set('permissions', $qb->createNamedParameter($share->getPermissions())) ->set('uid_owner', $qb->createNamedParameter($share->getShareOwner())) diff --git a/apps/sharebymail/tests/ShareByMailProviderTest.php b/apps/sharebymail/tests/ShareByMailProviderTest.php index e03fba72312..ae5d768b624 100644 --- a/apps/sharebymail/tests/ShareByMailProviderTest.php +++ b/apps/sharebymail/tests/ShareByMailProviderTest.php @@ -773,6 +773,8 @@ class ShareByMailProviderTest extends TestCase { $this->share->expects($this->once())->method('getSharedBy')->willReturn($sharedBy); $this->share->expects($this->any())->method('getNote')->willReturn($note); $this->share->expects($this->atLeastOnce())->method('getId')->willReturn($id); + $this->share->expects($this->atLeastOnce())->method('getNodeId')->willReturn($itemSource); + $this->share->expects($this->once())->method('getSharedWith')->willReturn($shareWith); $this->assertSame($this->share, $instance->update($this->share)