Skip to content

Commit

Permalink
Merge pull request #41296 from nextcloud/backport/41173/stable27
Browse files Browse the repository at this point in the history
[stable27] fix: Delete ghost versions of non-existing files
  • Loading branch information
solracsf authored Dec 5, 2023
2 parents 9fb8810 + de7e4e1 commit 4e2e475
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion apps/files_versions/lib/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -592,14 +592,17 @@ public static function expireOlderThanMaxForUser($uid) {
throw new DoesNotExistException('Could not find relative path of (' . $info->getPath() . ')');
}

$node = $userFolder->get(substr($path, 0, -strlen('.v'.$version)));
try {
$node = $userFolder->get(substr($path, 0, -strlen('.v'.$version)));
$versionEntity = $versionsMapper->findVersionForFileId($node->getId(), $version);
$versionEntities[$info->getId()] = $versionEntity;

if ($versionEntity->getLabel() !== '') {
return false;
}
} catch (NotFoundException $e) {
// Original node not found, delete the version
return true;
} catch (DoesNotExistException $ex) {
// Version on FS can have no equivalent in the DB if they were created before the version naming feature.
// So we ignore DoesNotExistException.
Expand Down

0 comments on commit 4e2e475

Please sign in to comment.