Skip to content

Commit 6cb5115

Browse files
authored
Merge pull request #60465 from nextcloud/share-cleanup-mounts
fix: update cached mounts when moving share in repair step
2 parents fdb9d12 + 22229f9 commit 6cb5115

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

apps/files_sharing/lib/Repair/CleanupShareTarget.php

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
namespace OCA\Files_Sharing\Repair;
1010

11+
use OC\Files\Cache\CacheEntry;
1112
use OC\Files\SetupManager;
1213
use OCA\Files_Sharing\ShareTargetValidator;
1314
use OCP\DB\QueryBuilder\IQueryBuilder;
@@ -111,12 +112,23 @@ public function run(IOutput $output) {
111112
);
112113
$newTarget = $userFolder->getRelativePath($absoluteNewTarget);
113114

114-
$this->moveShare((string)$shareInfo['id'], $newTarget);
115+
if ($newTarget !== $oldTarget) {
116+
$this->moveShare((string)$shareInfo['id'], $newTarget);
115117

116-
$oldMountPoint = "/{$recipient->getUID()}/files$oldTarget/";
117-
$newMountPoint = "/{$recipient->getUID()}/files$newTarget/";
118-
$userMounts[$newMountPoint] = $userMounts[$oldMountPoint];
119-
unset($userMounts[$oldMountPoint]);
118+
$oldMountPoint = "/{$recipient->getUID()}/files$oldTarget/";
119+
$newMountPoint = "/{$recipient->getUID()}/files$newTarget/";
120+
121+
/** @var ICachedMountInfo $mount */
122+
$mount = $userMounts[$oldMountPoint];
123+
$userMounts[$newMountPoint] = $mount;
124+
unset($userMounts[$oldMountPoint]);
125+
126+
$this->userMountCache->removeMount($oldMountPoint);
127+
$this->userMountCache->addMount($recipient, $newMountPoint, new CacheEntry([
128+
'fileid' => $mount->getRootId(),
129+
'storage' => $mount->getStorageId(),
130+
]), $mount->getMountProvider(), $mount->getMountId());
131+
}
120132
} catch (\Exception $e) {
121133
$msg = 'error cleaning up share target: ' . $e->getMessage();
122134
$this->logger->error($msg, ['exception' => $e, 'app' => 'files_sharing']);

0 commit comments

Comments
 (0)