summaryrefslogtreecommitdiffstats
path: root/apps/files_versions
diff options
context:
space:
mode:
authorblizzz <blizzz@arthur-schiwon.de>2023-02-16 14:08:29 +0100
committerGitHub <noreply@github.com>2023-02-16 14:08:29 +0100
commitfdc64b1ef68b18bff57c61adca338a8b752d106a (patch)
treec0fe14e3319f83d8936d6a5d7da92b4ee96b4e70 /apps/files_versions
parent98b998a2de2a0a013028fadec2e3618852442ce9 (diff)
parent21cd3b0e0d3b34ad0e3973aeac1d9a562456d258 (diff)
downloadnextcloud-server-fdc64b1ef68b18bff57c61adca338a8b752d106a.tar.gz
nextcloud-server-fdc64b1ef68b18bff57c61adca338a8b752d106a.zip
Merge pull request #36556 from nextcloud/artonge/fix/expiring_file_versions_empty_db
Handle empty DB while expiring versions
Diffstat (limited to 'apps/files_versions')
-rw-r--r--apps/files_versions/lib/Storage.php14
1 files changed, 10 insertions, 4 deletions
diff --git a/apps/files_versions/lib/Storage.php b/apps/files_versions/lib/Storage.php
index 2fd208cd364..75ca7e4bcee 100644
--- a/apps/files_versions/lib/Storage.php
+++ b/apps/files_versions/lib/Storage.php
@@ -52,6 +52,7 @@ use OCA\Files_Versions\Command\Expire;
use OCA\Files_Versions\Db\VersionsMapper;
use OCA\Files_Versions\Events\CreateVersionEvent;
use OCA\Files_Versions\Versions\IVersionManager;
+use OCP\AppFramework\Db\DoesNotExistException;
use OCP\Files\FileInfo;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
@@ -592,11 +593,16 @@ class Storage {
// Check that the version does not have a label.
$path = $versionsRoot->getRelativePath($info->getPath());
$node = $userFolder->get(substr($path, 0, -strlen('.v'.$version)));
- $versionEntity = $versionsMapper->findVersionForFileId($node->getId(), $version);
- $versionEntities[$info->getId()] = $versionEntity;
+ try {
+ $versionEntity = $versionsMapper->findVersionForFileId($node->getId(), $version);
+ $versionEntities[$info->getId()] = $versionEntity;
- if ($versionEntity->getLabel() !== '') {
- return false;
+ if ($versionEntity->getLabel() !== '') {
+ return false;
+ }
+ } 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.
}
// Check that the version's timestamp is lower than $threshold