Skip to content

Commit 8b8628d

Browse files
committed
fix: Delete ghost versions of non-existing files
Signed-off-by: Git'Fellow <[email protected]>
1 parent 009375b commit 8b8628d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

apps/files_versions/lib/Storage.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,14 +592,17 @@ public static function expireOlderThanMaxForUser($uid) {
592592
throw new DoesNotExistException('Could not find relative path of (' . $info->getPath() . ')');
593593
}
594594

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

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

0 commit comments

Comments
 (0)