richdocuments/lib/Backgroundjobs/Cleanup.php
Julius Härtl d491bfa9ff
Use FileCreatedFromTemplateEvent to inject the already existing empty template files for Collabora
Signed-off-by: Julius Härtl <jus@bitgrid.net>

Cleanup template loading

Signed-off-by: Julius Härtl <jus@bitgrid.net>

Fix template handling

Signed-off-by: Julius Härtl <jus@bitgrid.net>
2022-01-14 08:55:47 +01:00

49 lines
1.5 KiB
PHP

<?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();
}
}