Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/richdocuments.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Backgroundjobs/Cleanup.php')
-rw-r--r--lib/Backgroundjobs/Cleanup.php49
1 files changed, 49 insertions, 0 deletions
diff --git a/lib/Backgroundjobs/Cleanup.php b/lib/Backgroundjobs/Cleanup.php
new file mode 100644
index 00000000..e5adb55a
--- /dev/null
+++ b/lib/Backgroundjobs/Cleanup.php
@@ -0,0 +1,49 @@
+<?php
+/**
+ * @copyright Copyright (c) 2019, 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\Richdocuments\Backgroundjobs;
+
+use OC\BackgroundJob\TimedJob;
+use OCA\Richdocuments\Service\CapabilitiesService;
+use OCP\DB\QueryBuilder\IQueryBuilder;
+use OCP\IDBConnection;
+
+class Cleanup extends TimedJob {
+
+ /** @var IDBConnection */
+ private $db;
+
+ public function __construct(IDBConnection $db) {
+ $this->db = $db;
+
+ $this->setInterval(60*60);
+ }
+
+ protected function run($argument) {
+ // Expire template mappings for file creation
+ $query = $this->db->getQueryBuilder();
+ $query->delete('richdocuments_template')
+ ->where($query->expr()->lte('timestamp', $query->createNamedParameter(time() - 60, IQueryBuilder::PARAM_INT)));
+ $query->executeStatement();
+ }
+}