summaryrefslogtreecommitdiffstats
path: root/lib/repair
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2015-05-12 18:19:44 +0200
committerArthur Schiwon <blizzz@owncloud.com>2015-05-12 18:19:44 +0200
commitd6becb8d828aef0b06df3de51fe9bb0d9710801d (patch)
tree91ecae45f9ee3d5fe7e7854c17798842b056f865 /lib/repair
parente016ed55ff803f599414f72b7014be0911d95ec4 (diff)
downloadnextcloud-server-d6becb8d828aef0b06df3de51fe9bb0d9710801d.tar.gz
nextcloud-server-d6becb8d828aef0b06df3de51fe9bb0d9710801d.zip
add repair steps to get rid of old background jobs
Diffstat (limited to 'lib/repair')
-rw-r--r--lib/repair/dropoldjobs.php78
1 files changed, 78 insertions, 0 deletions
diff --git a/lib/repair/dropoldjobs.php b/lib/repair/dropoldjobs.php
new file mode 100644
index 00000000000..89d7f96a144
--- /dev/null
+++ b/lib/repair/dropoldjobs.php
@@ -0,0 +1,78 @@
+<?php
+/**
+ * @author Arthur Schiwon <blizzz@owncloud.com>
+ *
+ * @copyright Copyright (c) 2015, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * 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, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OC\Repair;
+
+use OC\Hooks\BasicEmitter;
+use OC\RepairStep;
+use OCP\BackgroundJob\IJobList;
+
+class DropOldJobs extends BasicEmitter implements RepairStep {
+
+ /** @var IJobList */
+ protected $jobList;
+
+ /**
+ * @param IJobList $jobList
+ */
+ public function __construct(IJobList $jobList) {
+ $this->jobList = $jobList;
+ }
+
+ /**
+ * Returns the step's name
+ *
+ * @return string
+ */
+ public function getName() {
+ return 'Drop old background jobs';
+ }
+
+ /**
+ * Run repair step.
+ * Must throw exception on error.
+ *
+ * @throws \Exception in case of failure
+ */
+ public function run() {
+ $oldJobs = $this->oldJobs();
+ foreach($oldJobs as $job) {
+ if($this->jobList->has($job['class'], $job['arguments'])) {
+ $this->jobList->remove($job['class'], $job['arguments']);
+ }
+ }
+ }
+
+ /**
+ * returns a list of old jobs as an associative array with keys 'class' and
+ * 'arguments'.
+ *
+ * @return array
+ */
+ public function oldJobs() {
+ return [
+ ['class' => 'OC_Cache_FileGlobalGC', 'arguments' => null],
+ ['class' => 'OC\Cache\FileGlobalGC', 'arguments' => null],
+ ];
+ }
+
+
+}