mirror of
https://github.com/nextcloud/server.git
synced 2026-02-03 20:41:22 -05:00
fix: don't stop the entire share target repair on an error
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
6c9898f89d
commit
0ce5cbab83
1 changed files with 23 additions and 12 deletions
|
|
@ -19,6 +19,7 @@ use OCP\IUserManager;
|
|||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\IRepairStep;
|
||||
use OCP\Share\IShare;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* @psalm-type ShareInfo = array{id: string|int, share_type: string, share_with: string, file_source: string, file_target: string}
|
||||
|
|
@ -41,6 +42,7 @@ class CleanupShareTarget implements IRepairStep {
|
|||
private readonly SetupManager $setupManager,
|
||||
private readonly IUserMountCache $userMountCache,
|
||||
private readonly IRootFolder $rootFolder,
|
||||
private readonly LoggerInterface $logger,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
@ -63,6 +65,9 @@ class CleanupShareTarget implements IRepairStep {
|
|||
|
||||
foreach ($this->getProblemShares() as $shareInfo) {
|
||||
$recipient = $this->userManager->getExistingUser($shareInfo['share_with']);
|
||||
if (!$recipient->isEnabled()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// since we ordered the share by user, we can reuse the last data until we get to the next user
|
||||
if ($lastUser !== $recipient->getUID()) {
|
||||
|
|
@ -81,20 +86,26 @@ class CleanupShareTarget implements IRepairStep {
|
|||
$absoluteNewTarget = $userFolder->getFullPath($newTarget);
|
||||
$targetParentNode = $this->rootFolder->get(dirname($absoluteNewTarget));
|
||||
|
||||
$absoluteNewTarget = $this->shareTargetValidator->generateUniqueTarget(
|
||||
(int)$shareInfo['file_source'],
|
||||
$absoluteNewTarget,
|
||||
$targetParentNode->getMountPoint(),
|
||||
$userMounts,
|
||||
);
|
||||
$newTarget = $userFolder->getRelativePath($absoluteNewTarget);
|
||||
try {
|
||||
$absoluteNewTarget = $this->shareTargetValidator->generateUniqueTarget(
|
||||
(int)$shareInfo['file_source'],
|
||||
$absoluteNewTarget,
|
||||
$targetParentNode->getMountPoint(),
|
||||
$userMounts,
|
||||
);
|
||||
$newTarget = $userFolder->getRelativePath($absoluteNewTarget);
|
||||
|
||||
$this->moveShare((string)$shareInfo['id'], $newTarget);
|
||||
$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/";
|
||||
$userMounts[$newMountPoint] = $userMounts[$oldMountPoint];
|
||||
unset($userMounts[$oldMountPoint]);
|
||||
} catch (\Exception $e) {
|
||||
$msg = 'error cleaning up share target: ' . $e->getMessage();
|
||||
$this->logger->error($msg, ['exception' => $e, 'app' => 'files_sharing']);
|
||||
$output->warning($msg);
|
||||
}
|
||||
|
||||
$output->advance();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue