Skip to content
Snippets Groups Projects
Commit 21cd3b0e authored by Louis Chemineau's avatar Louis Chemineau Committed by Louis (Rebase PR Action)
Browse files

Handle empty DB while expiring versions

Version on the FS can have no equivalent in the DB if they were created before the version naming feature. This makes sure that we catch the resulting exception and proceed as usual.

Fix https://github.com/nextcloud/server/issues/36541



Signed-off-by: default avatarLouis Chemineau <louis@chmn.me>
parent 7341d339
No related branches found
No related tags found
No related merge requests found
......@@ -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,12 +593,17 @@ 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)));
try {
$versionEntity = $versionsMapper->findVersionForFileId($node->getId(), $version);
$versionEntities[$info->getId()] = $versionEntity;
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
return $version < $threshold;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment