Skip to content

Commit

Permalink
Merge pull request #39786 from nextcloud/bugfix/version-expire-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
juliusknorr authored Aug 14, 2023
2 parents aefc3f8 + bbb7172 commit 2b7d037
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions apps/files_versions/lib/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,21 @@ public static function expire($filename, $uid) {
}

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]);
Expand Down

0 comments on commit 2b7d037

Please sign in to comment.