Skip to content

Commit

Permalink
fix: Delete ghost versions of non-existing files
Browse files Browse the repository at this point in the history
Signed-off-by: Git'Fellow <[email protected]>
  • Loading branch information
solracsf authored and blizzz committed Dec 4, 2023
1 parent d133375 commit de7e4e1
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 de7e4e1

Please sign in to comment.