aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_versions/lib/Expiration.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_versions/lib/Expiration.php')
-rw-r--r--apps/files_versions/lib/Expiration.php29
1 files changed, 20 insertions, 9 deletions
diff --git a/apps/files_versions/lib/Expiration.php b/apps/files_versions/lib/Expiration.php
index 26088aa9838..1e04d93379f 100644
--- a/apps/files_versions/lib/Expiration.php
+++ b/apps/files_versions/lib/Expiration.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -15,9 +16,6 @@ class Expiration {
// how long do we keep files a version if no other value is defined in the config file (unit: days)
public const NO_OBLIGATION = -1;
- /** @var ITimeFactory */
- private $timeFactory;
-
/** @var string */
private $retentionObligation;
@@ -30,12 +28,11 @@ class Expiration {
/** @var bool */
private $canPurgeToSaveSpace;
- /** @var LoggerInterface */
- private $logger;
-
- public function __construct(IConfig $config, ITimeFactory $timeFactory, LoggerInterface $logger) {
- $this->timeFactory = $timeFactory;
- $this->logger = $logger;
+ public function __construct(
+ IConfig $config,
+ private ITimeFactory $timeFactory,
+ private LoggerInterface $logger,
+ ) {
$this->retentionObligation = $config->getSystemValue('versions_retention_obligation', 'auto');
if ($this->retentionObligation !== 'disabled') {
@@ -103,6 +100,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