aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_versions
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2023-08-10 09:26:12 +0200
committerJulius Härtl <jus@bitgrid.net>2023-08-14 19:31:41 +0200
commitbbb71722206f966df25e4f7992e4206468a6754f (patch)
tree4e9676e49780d27073f55c87b798302ec8091f20 /apps/files_versions
parent2ea6c5364dfd672576824b65c1120c17b8c25c0f (diff)
downloadnextcloud-server-bbb71722206f966df25e4f7992e4206468a6754f.tar.gz
nextcloud-server-bbb71722206f966df25e4f7992e4206468a6754f.zip
fix: Also cleanup version metadata if expiring
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'apps/files_versions')
-rw-r--r--apps/files_versions/lib/Storage.php15
1 files changed, 15 insertions, 0 deletions
diff --git a/apps/files_versions/lib/Storage.php b/apps/files_versions/lib/Storage.php
index 676d94d2fb7..426d5931ba9 100644
--- a/apps/files_versions/lib/Storage.php
+++ b/apps/files_versions/lib/Storage.php
@@ -913,6 +913,21 @@ class Storage {
}
foreach ($toDelete as $key => $path) {
+ // Make sure to cleanup version table relations as expire does not pass deleteVersion
+ try {
+ /** @var VersionsMapper $versionsMapper */
+ $versionsMapper = \OC::$server->get(VersionsMapper::class);
+ $file = \OC::$server->get(IRootFolder::class)->getUserFolder($uid)->get($filename);
+ $pathparts = pathinfo($path);
+ $timestamp = (int)substr($pathparts['extension'] ?? '', 1);
+ $versionEntity = $versionsMapper->findVersionForFileId($file->getId(), $timestamp);
+ if ($versionEntity->getLabel() !== '') {
+ continue;
+ }
+ $versionsMapper->delete($versionEntity);
+ } catch (DoesNotExistException $e) {
+ }
+
\OC_Hook::emit('\OCP\Versions', 'preDelete', ['path' => $path, 'trigger' => self::DELETE_TRIGGER_QUOTA_EXCEEDED]);
self::deleteVersion($versionsFileview, $path);
\OC_Hook::emit('\OCP\Versions', 'delete', ['path' => $path, 'trigger' => self::DELETE_TRIGGER_QUOTA_EXCEEDED]);