fix: target-repair: handle cases where the parent folder doesn't exist

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2026-02-06 14:40:51 +01:00
parent 285decb94a
commit b279fc0ed7
No known key found for this signature in database
GPG key ID: 42B69D8A64526EFB

View file

@ -13,6 +13,7 @@ use OCA\Files_Sharing\ShareTargetValidator;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\Files\IRootFolder;
use OCP\Files\Mount\IMountManager;
use OCP\Files\NotFoundException;
use OCP\IDBConnection;
use OCP\IUserManager;
use OCP\Migration\IOutput;
@ -81,7 +82,12 @@ class CleanupShareTarget implements IRepairStep {
$oldTarget = $shareInfo['file_target'];
$newTarget = $this->cleanTarget($oldTarget);
$absoluteNewTarget = $userFolder->getFullPath($newTarget);
$targetParentNode = $this->rootFolder->get(dirname($absoluteNewTarget));
try {
$targetParentNode = $this->rootFolder->get(dirname($absoluteNewTarget));
} catch (NotFoundException) {
$absoluteNewTarget = $userFolder->getFullPath(basename($newTarget));
$targetParentNode = $userFolder;
}
try {
$absoluteNewTarget = $this->shareTargetValidator->generateUniqueTarget(