Skip to content

Commit c980842

Browse files
authored
Merge pull request #48616 from nextcloud/backport/48597/stable28
[stable28] Fix email share transfer accross storages
2 parents c321efd + 441ca8b commit c980842

3 files changed

Lines changed: 8 additions & 1 deletion

File tree

apps/files/lib/Service/OwnershipTransferService.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ private function restoreShares(
439439

440440
foreach ($shares as ['share' => $share, 'suffix' => $suffix]) {
441441
try {
442+
$output->writeln('Transfering share ' . $share->getId() . ' of type ' . $share->getShareType(), OutputInterface::VERBOSITY_VERBOSE);
442443
if ($share->getShareType() === IShare::TYPE_USER &&
443444
$share->getSharedWith() === $destinationUid) {
444445
// Unmount the shares before deleting, so we don't try to get the storage later on.
@@ -476,6 +477,7 @@ private function restoreShares(
476477
// Try to get the new ID from the target path and suffix of the share
477478
$node = $rootFolder->get(Filesystem::normalizePath($targetLocation . '/' . $suffix));
478479
$newNodeId = $node->getId();
480+
$output->writeln('Had to change node id to ' . $newNodeId, OutputInterface::VERBOSITY_VERY_VERBOSE);
479481
}
480482
$share->setNodeId($newNodeId);
481483

apps/sharebymail/lib/ShareByMailProvider.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,11 +673,14 @@ public function update(IShare $share, ?string $plainTextPassword = null): IShare
673673
}
674674

675675
/*
676-
* We allow updating the permissions and password of mail shares
676+
* We allow updating mail shares
677677
*/
678678
$qb = $this->dbConnection->getQueryBuilder();
679679
$qb->update('share')
680680
->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId())))
681+
->set('item_source', $qb->createNamedParameter($share->getNodeId()))
682+
->set('file_source', $qb->createNamedParameter($share->getNodeId()))
683+
->set('share_with', $qb->createNamedParameter($share->getSharedWith()))
681684
->set('permissions', $qb->createNamedParameter($share->getPermissions()))
682685
->set('uid_owner', $qb->createNamedParameter($share->getShareOwner()))
683686
->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy()))

apps/sharebymail/tests/ShareByMailProviderTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,8 @@ public function testUpdate() {
643643
$this->share->expects($this->once())->method('getSharedBy')->willReturn($sharedBy);
644644
$this->share->expects($this->any())->method('getNote')->willReturn($note);
645645
$this->share->expects($this->atLeastOnce())->method('getId')->willReturn($id);
646+
$this->share->expects($this->atLeastOnce())->method('getNodeId')->willReturn($itemSource);
647+
$this->share->expects($this->once())->method('getSharedWith')->willReturn($shareWith);
646648

647649
$this->assertSame($this->share,
648650
$instance->update($this->share)

0 commit comments

Comments
 (0)