mirror of
https://github.com/nextcloud/server.git
synced 2026-06-10 09:13:19 -04:00
Merge pull request #51025 from nextcloud/backport/50903/stable31
[stable31] fix(files_versions): Do not expire versions newer than min age
This commit is contained in:
commit
d632679d8f
2 changed files with 23 additions and 1 deletions
|
|
@ -98,6 +98,20 @@ class Expiration {
|
|||
return $isOlderThanMax || $isMinReached;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get minimal retention obligation as a timestamp
|
||||
*
|
||||
* @return int|false
|
||||
*/
|
||||
public function getMinAgeAsTimestamp() {
|
||||
$minAge = false;
|
||||
if ($this->isEnabled() && $this->minAge !== self::NO_OBLIGATION) {
|
||||
$time = $this->timeFactory->getTime();
|
||||
$minAge = $time - ($this->minAge * 86400);
|
||||
}
|
||||
return $minAge;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get maximal retention obligation as a timestamp
|
||||
*
|
||||
|
|
|
|||
|
|
@ -696,7 +696,15 @@ class Storage {
|
|||
$expiration = self::getExpiration();
|
||||
|
||||
if ($expiration->shouldAutoExpire()) {
|
||||
[$toDelete, $size] = self::getAutoExpireList($time, $versions);
|
||||
// Exclude versions that are newer than the minimum age from the auto expiration logic.
|
||||
$minAge = $expiration->getMinAgeAsTimestamp();
|
||||
if ($minAge !== false) {
|
||||
$versionsToAutoExpire = array_filter($versions, fn ($version) => $version['version'] < $minAge);
|
||||
} else {
|
||||
$versionsToAutoExpire = $versions;
|
||||
}
|
||||
|
||||
[$toDelete, $size] = self::getAutoExpireList($time, $versionsToAutoExpire);
|
||||
} else {
|
||||
$size = 0;
|
||||
$toDelete = []; // versions we want to delete
|
||||
|
|
|
|||
Loading…
Reference in a new issue