aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/BackgroundJob
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2018-04-23 22:32:41 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2018-04-26 10:35:37 +0200
commitb6c58e75b754fc7a5f6873b51934be16a8365d8f (patch)
tree088d56a227ea0ec9990e4a8884a54008b378c734 /apps/dav/lib/BackgroundJob
parent042340ccf6e7d6408390b91f6904de0425bb3c07 (diff)
downloadnextcloud-server-b6c58e75b754fc7a5f6873b51934be16a8365d8f.tar.gz
nextcloud-server-b6c58e75b754fc7a5f6873b51934be16a8365d8f.zip
Add backgroundjob to cleanup expired direct links
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/dav/lib/BackgroundJob')
-rw-r--r--apps/dav/lib/BackgroundJob/CleanupDirectLinksJob.php50
1 files changed, 50 insertions, 0 deletions
diff --git a/apps/dav/lib/BackgroundJob/CleanupDirectLinksJob.php b/apps/dav/lib/BackgroundJob/CleanupDirectLinksJob.php
new file mode 100644
index 00000000000..ba1049071ad
--- /dev/null
+++ b/apps/dav/lib/BackgroundJob/CleanupDirectLinksJob.php
@@ -0,0 +1,50 @@
+<?php
+declare(strict_types=1);
+/**
+ * @copyright 2018, Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @author Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\DAV\BackgroundJob;
+
+use OC\BackgroundJob\TimedJob;
+use OCA\DAV\Db\DirectMapper;
+use OCP\AppFramework\Utility\ITimeFactory;
+
+class CleanupDirectLinksJob extends TimedJob {
+ /** @var ITimeFactory */
+ private $timeFactory;
+
+ /** @var DirectMapper */
+ private $mapper;
+
+ public function __construct(ITimeFactory $timeFactory, DirectMapper $mapper) {
+ $this->setInterval(60*60*24);
+
+ $this->timeFactory = $timeFactory;
+ $this->mapper = $mapper;
+ }
+
+ protected function run($argument) {
+ // Delete all shares expired 24 hours ago
+ $this->mapper->deleteExpired($this->timeFactory->getTime() - 60*60*24);
+ }
+
+}