From 8b8628d4977d0836419fa7dcbcce1fd4ea5efd84 Mon Sep 17 00:00:00 2001 From: Git'Fellow <12234510+solracsf@users.noreply.github.com> Date: Sat, 28 Oct 2023 14:47:19 +0200 Subject: [PATCH] fix: Delete ghost versions of non-existing files Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com> --- apps/files_versions/lib/Storage.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/files_versions/lib/Storage.php b/apps/files_versions/lib/Storage.php index 426d5931ba9..997d6788a6f 100644 --- a/apps/files_versions/lib/Storage.php +++ b/apps/files_versions/lib/Storage.php @@ -592,14 +592,17 @@ class Storage { 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. -- 2.39.5