summaryrefslogtreecommitdiffstats
path: root/apps/files_trashbin/lib
diff options
context:
space:
mode:
authorDaniel Kesselberg <mail@danielkesselberg.de>2021-10-07 21:34:16 +0200
committerDaniel Kesselberg <mail@danielkesselberg.de>2021-10-11 12:30:36 +0200
commitb0d1ad57777b0b09e7176cdadbb5f4dd6a060d05 (patch)
treef612159b4a0e7ed9076abaa91ad4c12b233a1003 /apps/files_trashbin/lib
parent4a1a9d6821fa61885080793ab34cdb9f4d2d0057 (diff)
downloadnextcloud-server-b0d1ad57777b0b09e7176cdadbb5f4dd6a060d05.tar.gz
nextcloud-server-b0d1ad57777b0b09e7176cdadbb5f4dd6a060d05.zip
Add configuration flag to disable the background job for files_trashbin
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
Diffstat (limited to 'apps/files_trashbin/lib')
-rw-r--r--apps/files_trashbin/lib/BackgroundJob/ExpireTrash.php24
1 files changed, 16 insertions, 8 deletions
diff --git a/apps/files_trashbin/lib/BackgroundJob/ExpireTrash.php b/apps/files_trashbin/lib/BackgroundJob/ExpireTrash.php
index d319edd91dc..9e35273544b 100644
--- a/apps/files_trashbin/lib/BackgroundJob/ExpireTrash.php
+++ b/apps/files_trashbin/lib/BackgroundJob/ExpireTrash.php
@@ -30,33 +30,35 @@ use OCA\Files_Trashbin\AppInfo\Application;
use OCA\Files_Trashbin\Expiration;
use OCA\Files_Trashbin\Helper;
use OCA\Files_Trashbin\Trashbin;
+use OCP\IConfig;
use OCP\IUser;
use OCP\IUserManager;
class ExpireTrash extends \OC\BackgroundJob\TimedJob {
+ /** @var IConfig */
+ private $config;
+
/**
* @var Expiration
*/
private $expiration;
-
+
/**
* @var IUserManager
*/
private $userManager;
- /**
- * @param IUserManager|null $userManager
- * @param Expiration|null $expiration
- */
- public function __construct(IUserManager $userManager = null,
+ public function __construct(IConfig $config = null,
+ IUserManager $userManager = null,
Expiration $expiration = null) {
// Run once per 30 minutes
$this->setInterval(60 * 30);
- if (is_null($expiration) || is_null($userManager)) {
+ if ($config === null || $expiration === null || $userManager === null) {
$this->fixDIForJobs();
} else {
+ $this->config = $config;
$this->userManager = $userManager;
$this->expiration = $expiration;
}
@@ -65,6 +67,7 @@ class ExpireTrash extends \OC\BackgroundJob\TimedJob {
protected function fixDIForJobs() {
/** @var Application $application */
$application = \OC::$server->query(Application::class);
+ $this->config = $application->getContainer()->get(IConfig::class);
$this->userManager = \OC::$server->getUserManager();
$this->expiration = $application->getContainer()->query('Expiration');
}
@@ -74,6 +77,11 @@ class ExpireTrash extends \OC\BackgroundJob\TimedJob {
* @throws \Exception
*/
protected function run($argument) {
+ $backgroundJob = $this->config->getAppValue('files_trashbin', 'background_job_expire_trash', 'yes');
+ if ($backgroundJob === 'no') {
+ return;
+ }
+
$maxAge = $this->expiration->getMaxAgeAsTimestamp();
if (!$maxAge) {
return;
@@ -87,7 +95,7 @@ class ExpireTrash extends \OC\BackgroundJob\TimedJob {
$dirContent = Helper::getTrashFiles('/', $uid, 'mtime');
Trashbin::deleteExpiredFiles($dirContent, $uid);
});
-
+
\OC_Util::tearDownFS();
}