aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_versions
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_versions')
-rw-r--r--apps/files_versions/lib/Expiration.php14
-rw-r--r--apps/files_versions/lib/Storage.php10
2 files changed, 23 insertions, 1 deletions
diff --git a/apps/files_versions/lib/Expiration.php b/apps/files_versions/lib/Expiration.php
index b84756212e4..5ef749ad115 100644
--- a/apps/files_versions/lib/Expiration.php
+++ b/apps/files_versions/lib/Expiration.php
@@ -99,6 +99,20 @@ class Expiration {
}
/**
+ * 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
*
* @return int|false
diff --git a/apps/files_versions/lib/Storage.php b/apps/files_versions/lib/Storage.php
index 11e6bff6b6b..dcf39a5e477 100644
--- a/apps/files_versions/lib/Storage.php
+++ b/apps/files_versions/lib/Storage.php
@@ -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