diff --git a/apps/files_sharing/lib/Repair/CleanupShareTarget.php b/apps/files_sharing/lib/Repair/CleanupShareTarget.php index 880c2a15af6c6..6ae708cc7d2e5 100644 --- a/apps/files_sharing/lib/Repair/CleanupShareTarget.php +++ b/apps/files_sharing/lib/Repair/CleanupShareTarget.php @@ -8,6 +8,7 @@ namespace OCA\Files_Sharing\Repair; +use OC\Files\Cache\CacheEntry; use OC\Files\SetupManager; use OCA\Files_Sharing\ShareTargetValidator; use OCP\DB\QueryBuilder\IQueryBuilder; @@ -111,12 +112,23 @@ public function run(IOutput $output) { ); $newTarget = $userFolder->getRelativePath($absoluteNewTarget); - $this->moveShare((string)$shareInfo['id'], $newTarget); + if ($newTarget !== $oldTarget) { + $this->moveShare((string)$shareInfo['id'], $newTarget); - $oldMountPoint = "/{$recipient->getUID()}/files$oldTarget/"; - $newMountPoint = "/{$recipient->getUID()}/files$newTarget/"; - $userMounts[$newMountPoint] = $userMounts[$oldMountPoint]; - unset($userMounts[$oldMountPoint]); + $oldMountPoint = "/{$recipient->getUID()}/files$oldTarget/"; + $newMountPoint = "/{$recipient->getUID()}/files$newTarget/"; + + /** @var ICachedMountInfo $mount */ + $mount = $userMounts[$oldMountPoint]; + $userMounts[$newMountPoint] = $mount; + unset($userMounts[$oldMountPoint]); + + $this->userMountCache->removeMount($oldMountPoint); + $this->userMountCache->addMount($recipient, $newMountPoint, new CacheEntry([ + 'fileid' => $mount->getRootId(), + 'storage' => $mount->getStorageId(), + ]), $mount->getMountProvider(), $mount->getMountId()); + } } catch (\Exception $e) { $msg = 'error cleaning up share target: ' . $e->getMessage(); $this->logger->error($msg, ['exception' => $e, 'app' => 'files_sharing']);