]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix: Delete ghost versions of non-existing files 41297/head
authorGit'Fellow <12234510+solracsf@users.noreply.github.com>
Sat, 28 Oct 2023 12:47:19 +0000 (14:47 +0200)
committerGit'Fellow <12234510+solracsf@users.noreply.github.com>
Tue, 14 Nov 2023 22:09:32 +0000 (23:09 +0100)
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
apps/files_versions/lib/Storage.php

index 426d5931ba9d5d4cff201d95740a2ecd267d9bd9..997d6788a6f864911c60505ac35c9b69dce195e7 100644 (file)
@@ -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.