Skip to content

Commit

Permalink
Merge pull request #41173 from nextcloud/deleteGhostVersion
Browse files Browse the repository at this point in the history
fix: Delete ghost versions of non-existing files
  • Loading branch information
artonge committed Nov 6, 2023
2 parents 738faf4 + ffeef99 commit 40c8e58
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion apps/files_versions/lib/Storage.php
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 40c8e58

Please sign in to comment.