Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Also cleanup version metadata if expiring #39786

Merged
merged 1 commit into from
Aug 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading