aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2015-06-02 09:11:33 +0200
committerMorris Jobke <hey@morrisjobke.de>2015-06-02 09:11:33 +0200
commitcf2c599218f01c1351cee2e4e48ee4b430f55287 (patch)
tree67daea46a2252a53c0da05d9de59c75c8e90996e /lib
parentbaca5c60c010cb26d3845ad3863fe59e16a0a042 (diff)
parente5a91fc185c4c992469e19d37c4ad3691ed1d3ae (diff)
downloadnextcloud-server-cf2c599218f01c1351cee2e4e48ee4b430f55287.tar.gz
nextcloud-server-cf2c599218f01c1351cee2e4e48ee4b430f55287.zip
Merge pull request #16200 from owncloud/kill-globalfilecache
Drop file caching
Diffstat (limited to 'lib')
-rw-r--r--lib/base.php14
-rw-r--r--lib/private/backgroundjob/joblist.php3
-rw-r--r--lib/private/cache.php129
-rw-r--r--lib/private/cache/broker.php80
-rw-r--r--lib/private/cache/file.php174
-rw-r--r--lib/private/cache/fileglobal.php107
-rw-r--r--lib/private/cache/fileglobalgc.php80
-rw-r--r--lib/private/cache/usercache.php93
-rw-r--r--lib/private/repair.php2
-rw-r--r--lib/private/server.php12
-rw-r--r--lib/repair/dropoldjobs.php78
11 files changed, 87 insertions, 685 deletions
diff --git a/lib/base.php b/lib/base.php
index 09159dc22aa..77b0a89a90b 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -652,7 +652,6 @@ class OC {
OC_User::setupBackends();
}
- self::registerCacheHooks();
self::registerFilesystemHooks();
if (\OC::$server->getSystemConfig()->getValue('enable_previews', true)) {
self::registerPreviewHooks();
@@ -737,19 +736,6 @@ class OC {
/**
* register hooks for the cache
*/
- public static function registerCacheHooks() {
- if (\OC::$server->getSystemConfig()->getValue('installed', false) && !\OCP\Util::needUpgrade()) { //don't try to do this before we are properly setup
- \OCP\BackgroundJob::registerJob('OC\Cache\FileGlobalGC');
-
- // NOTE: This will be replaced to use OCP
- $userSession = \OC_User::getUserSession();
- $userSession->listen('postLogin', '\OC\Cache\File', 'loginListener');
- }
- }
-
- /**
- * register hooks for the cache
- */
public static function registerLogRotate() {
$systemConfig = \OC::$server->getSystemConfig();
if ($systemConfig->getValue('installed', false) && $systemConfig->getValue('log_rotate_size', false) && !\OCP\Util::needUpgrade()) {
diff --git a/lib/private/backgroundjob/joblist.php b/lib/private/backgroundjob/joblist.php
index c568873bb46..e8915b47f24 100644
--- a/lib/private/backgroundjob/joblist.php
+++ b/lib/private/backgroundjob/joblist.php
@@ -172,9 +172,6 @@ class JobList implements IJobList {
/**
* @var Job $job
*/
- if ($class === 'OC_Cache_FileGlobalGC') {
- $class = '\OC\Cache\FileGlobalGC';
- }
if (!class_exists($class)) {
// job from disabled app or old version of an app, no need to do anything
return null;
diff --git a/lib/private/cache.php b/lib/private/cache.php
deleted file mode 100644
index 095a1ddcd4d..00000000000
--- a/lib/private/cache.php
+++ /dev/null
@@ -1,129 +0,0 @@
-<?php
-/**
- * @author Bart Visscher <bartv@thisnet.nl>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <icewind@owncloud.com>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- * @author Thomas Tanghus <thomas@tanghus.net>
- *
- * @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;
-
-class Cache {
- /**
- * @var Cache $user_cache
- */
- static protected $user_cache;
- /**
- * @var Cache $global_cache
- */
- static protected $global_cache;
-
- /**
- * get the global cache
- * @return Cache
- */
- static public function getGlobalCache() {
- if (!self::$global_cache) {
- self::$global_cache = new Cache\FileGlobal();
- }
- return self::$global_cache;
- }
-
- /**
- * get the user cache
- * @return Cache
- */
- static public function getUserCache() {
- if (!self::$user_cache) {
- self::$user_cache = new Cache\File();
- }
- return self::$user_cache;
- }
-
- /**
- * get a value from the user cache
- * @param string $key
- * @return mixed
- */
- static public function get($key) {
- $user_cache = self::getUserCache();
- return $user_cache->get($key);
- }
-
- /**
- * set a value in the user cache
- * @param string $key
- * @param mixed $value
- * @param int $ttl
- * @return bool
- */
- static public function set($key, $value, $ttl=0) {
- if (empty($key)) {
- return false;
- }
- $user_cache = self::getUserCache();
- return $user_cache->set($key, $value, $ttl);
- }
-
- /**
- * check if a value is set in the user cache
- * @param string $key
- * @return bool
- */
- static public function hasKey($key) {
- $user_cache = self::getUserCache();
- return $user_cache->hasKey($key);
- }
-
- /**
- * remove an item from the user cache
- * @param string $key
- * @return bool
- */
- static public function remove($key) {
- $user_cache = self::getUserCache();
- return $user_cache->remove($key);
- }
-
- /**
- * clear the user cache of all entries starting with a prefix
- * @param string $prefix (optional)
- * @return bool
- */
- static public function clear($prefix='') {
- $user_cache = self::getUserCache();
- return $user_cache->clear($prefix);
- }
-
- /**
- * creates cache key based on the files given
- * @param string[] $files
- * @return string
- */
- static public function generateCacheKeyFromFiles($files) {
- $key = '';
- sort($files);
- foreach($files as $file) {
- $stat = stat($file);
- $key .= $file.$stat['mtime'].$stat['size'];
- }
- return md5($key);
- }
-}
diff --git a/lib/private/cache/broker.php b/lib/private/cache/broker.php
deleted file mode 100644
index a52fb220f00..00000000000
--- a/lib/private/cache/broker.php
+++ /dev/null
@@ -1,80 +0,0 @@
-<?php
-/**
- * @author Bart Visscher <bartv@thisnet.nl>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <icewind@owncloud.com>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- * @author Thomas Tanghus <thomas@tanghus.net>
- *
- * @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\Cache;
-
-class Broker {
-
- /**
- * @var \OC\Cache
- */
- protected $fast_cache;
-
- /**
- * @var \OC\Cache
- */
- protected $slow_cache;
-
- public function __construct($fast_cache, $slow_cache) {
- $this->fast_cache = $fast_cache;
- $this->slow_cache = $slow_cache;
- }
-
- public function get($key) {
- if ($r = $this->fast_cache->get($key)) {
- return $r;
- }
- return $this->slow_cache->get($key);
- }
-
- public function set($key, $value, $ttl=0) {
- if (!$this->fast_cache->set($key, $value, $ttl)) {
- if ($this->fast_cache->hasKey($key)) {
- $this->fast_cache->remove($key);
- }
- return $this->slow_cache->set($key, $value, $ttl);
- }
- return true;
- }
-
- public function hasKey($key) {
- if ($this->fast_cache->hasKey($key)) {
- return true;
- }
- return $this->slow_cache->hasKey($key);
- }
-
- public function remove($key) {
- if ($this->fast_cache->remove($key)) {
- return true;
- }
- return $this->slow_cache->remove($key);
- }
-
- public function clear($prefix='') {
- $this->fast_cache->clear($prefix);
- $this->slow_cache->clear($prefix);
- }
-}
diff --git a/lib/private/cache/file.php b/lib/private/cache/file.php
deleted file mode 100644
index c70698eb7f8..00000000000
--- a/lib/private/cache/file.php
+++ /dev/null
@@ -1,174 +0,0 @@
-<?php
-/**
- * @author Arthur Schiwon <blizzz@owncloud.com>
- * @author Bart Visscher <bartv@thisnet.nl>
- * @author Björn Schießle <schiessle@owncloud.com>
- * @author Jörn Friedrich Dreyer <jfd@butonic.de>
- * @author Michael Gapczynski <GapczynskiM@gmail.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <icewind@owncloud.com>
- * @author Robin McCorkell <rmccorkell@karoshi.org.uk>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- * @author Thomas Tanghus <thomas@tanghus.net>
- * @author Vincent Petry <pvince81@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\Cache;
-
-use OC\Files\Filesystem;
-use OC\Files\View;
-use OCP\Security\ISecureRandom;
-
-class File {
- protected $storage;
-
- /**
- * Returns the cache storage for the logged in user
- *
- * @return \OC\Files\View cache storage
- */
- protected function getStorage() {
- if (isset($this->storage)) {
- return $this->storage;
- }
- if (\OC_User::isLoggedIn()) {
- $rootView = new View();
- $user = \OC::$server->getUserSession()->getUser();
- Filesystem::initMountPoints($user->getUID());
- if (!$rootView->file_exists('/' . $user->getUID() . '/cache')) {
- $rootView->mkdir('/' . $user->getUID() . '/cache');
- }
- $this->storage = new View('/' . $user->getUID() . '/cache');
- return $this->storage;
- } else {
- \OC_Log::write('core', 'Can\'t get cache storage, user not logged in', \OC_Log::ERROR);
- throw new \OC\ForbiddenException('Can\t get cache storage, user not logged in');
- }
- }
-
- /**
- * @param string $key
- */
- public function get($key) {
- $result = null;
- if ($this->hasKey($key)) {
- $storage = $this->getStorage();
- $result = $storage->file_get_contents($key);
- }
- return $result;
- }
-
- /**
- * Returns the size of the stored/cached data
- *
- * @param string $key
- * @return int
- */
- public function size($key) {
- $result = 0;
- if ($this->hasKey($key)) {
- $storage = $this->getStorage();
- $result = $storage->filesize($key);
- }
- return $result;
- }
-
- /**
- * @param string $key
- */
- public function set($key, $value, $ttl = 0) {
- $storage = $this->getStorage();
- $result = false;
- // unique id to avoid chunk collision, just in case
- $uniqueId = \OC::$server->getSecureRandom()->getLowStrengthGenerator()->generate(
- 16,
- ISecureRandom::CHAR_DIGITS . ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_UPPER
- );
-
- // use part file to prevent hasKey() to find the key
- // while it is being written
- $keyPart = $key . '.' . $uniqueId . '.part';
- if ($storage and $storage->file_put_contents($keyPart, $value)) {
- if ($ttl === 0) {
- $ttl = 86400; // 60*60*24
- }
- $result = $storage->touch($keyPart, time() + $ttl);
- $result &= $storage->rename($keyPart, $key);
- }
- return $result;
- }
-
- public function hasKey($key) {
- $storage = $this->getStorage();
- if ($storage && $storage->is_file($key) && $storage->isReadable($key)) {
- return true;
- }
- return false;
- }
-
- /**
- * @param string $key
- */
- public function remove($key) {
- $storage = $this->getStorage();
- if (!$storage) {
- return false;
- }
- return $storage->unlink($key);
- }
-
- public function clear($prefix = '') {
- $storage = $this->getStorage();
- if ($storage and $storage->is_dir('/')) {
- $dh = $storage->opendir('/');
- if (is_resource($dh)) {
- while (($file = readdir($dh)) !== false) {
- if ($file != '.' and $file != '..' and ($prefix === '' || strpos($file, $prefix) === 0)) {
- $storage->unlink('/' . $file);
- }
- }
- }
- }
- return true;
- }
-
- public function gc() {
- $storage = $this->getStorage();
- if ($storage and $storage->is_dir('/')) {
- $now = time();
- $dh = $storage->opendir('/');
- if (!is_resource($dh)) {
- return null;
- }
- while (($file = readdir($dh)) !== false) {
- if ($file != '.' and $file != '..') {
- $mtime = $storage->filemtime('/' . $file);
- if ($mtime < $now) {
- $storage->unlink('/' . $file);
- }
- }
- }
- }
- }
-
- public static function loginListener() {
- $c = new self();
- $c->gc();
- }
-}
diff --git a/lib/private/cache/fileglobal.php b/lib/private/cache/fileglobal.php
deleted file mode 100644
index b808c0dd8ff..00000000000
--- a/lib/private/cache/fileglobal.php
+++ /dev/null
@@ -1,107 +0,0 @@
-<?php
-/**
- * @author Arthur Schiwon <blizzz@owncloud.com>
- * @author Bart Visscher <bartv@thisnet.nl>
- * @author Jörn Friedrich Dreyer <jfd@butonic.de>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- * @author Thomas Tanghus <thomas@tanghus.net>
- *
- * @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\Cache;
-
-class FileGlobal {
- static protected function getCacheDir() {
- $cache_dir = get_temp_dir().'/owncloud-' . \OC_Util::getInstanceId().'/';
- if (!is_dir($cache_dir)) {
- mkdir($cache_dir);
- }
- return $cache_dir;
- }
-
- protected function fixKey($key) {
- return str_replace('/', '_', $key);
- }
-
- /**
- * @param string $key
- */
- public function get($key) {
- $key = $this->fixKey($key);
- if ($this->hasKey($key)) {
- $cache_dir = self::getCacheDir();
- return file_get_contents($cache_dir.$key);
- }
- return null;
- }
-
- /**
- * @param string $key
- * @param string $value
- */
- public function set($key, $value, $ttl=0) {
- $key = $this->fixKey($key);
- $cache_dir = self::getCacheDir();
- if ($cache_dir and file_put_contents($cache_dir.$key, $value)) {
- if ($ttl === 0) {
- $ttl = 86400; // 60*60*24
- }
- return touch($cache_dir.$key, time() + $ttl);
- }
- return false;
- }
-
- public function hasKey($key) {
- $key = $this->fixKey($key);
- $cache_dir = self::getCacheDir();
- if ($cache_dir && is_file($cache_dir.$key) && is_readable($cache_dir.$key)) {
- $mtime = filemtime($cache_dir.$key);
- if ($mtime < time()) {
- unlink($cache_dir.$key);
- return false;
- }
- return true;
- }
- return false;
- }
-
- public function remove($key) {
- $cache_dir = self::getCacheDir();
- if(!$cache_dir) {
- return false;
- }
- $key = $this->fixKey($key);
- return unlink($cache_dir.$key);
- }
-
- public function clear($prefix='') {
- $cache_dir = self::getCacheDir();
- $prefix = $this->fixKey($prefix);
- if($cache_dir and is_dir($cache_dir)) {
- $dh=opendir($cache_dir);
- if(is_resource($dh)) {
- while (($file = readdir($dh)) !== false) {
- if($file!='.' and $file!='..' and ($prefix==='' || strpos($file, $prefix) === 0)) {
- unlink($cache_dir.$file);
- }
- }
- }
- }
- }
-}
diff --git a/lib/private/cache/fileglobalgc.php b/lib/private/cache/fileglobalgc.php
deleted file mode 100644
index 0d966282383..00000000000
--- a/lib/private/cache/fileglobalgc.php
+++ /dev/null
@@ -1,80 +0,0 @@
-<?php
-/**
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <icewind@owncloud.com>
- * @author Robin McCorkell <rmccorkell@karoshi.org.uk>
- * @author Thomas Tanghus <thomas@tanghus.net>
- *
- * @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\Cache;
-
-use OC\BackgroundJob\Job;
-use OCP\IConfig;
-
-class FileGlobalGC extends Job {
- // only do cleanup every 5 minutes
- const CLEANUP_TTL_SEC = 300;
-
- public function run($argument) {
- $this->gc(\OC::$server->getConfig(), $this->getCacheDir());
- }
-
- protected function getCacheDir() {
- return get_temp_dir() . '/owncloud-' . \OC_Util::getInstanceId() . '/';
- }
-
- /**
- * @param string $cacheDir
- * @param int $now
- * @return string[]
- */
- public function getExpiredPaths($cacheDir, $now) {
- $files = scandir($cacheDir);
- $files = array_filter($files, function ($file) {
- return $file != '.' and $file != '..';
- });
- $paths = array_map(function ($file) use ($cacheDir) {
- return $cacheDir . $file;
- }, $files);
- return array_values(array_filter($paths, function ($path) use ($now) {
- return is_file($path) and (filemtime($path) < $now);
- }));
- }
-
- /**
- * @param \OCP\IConfig $config
- * @param string $cacheDir
- */
- public function gc(IConfig $config, $cacheDir) {
- $lastRun = $config->getAppValue('core', 'global_cache_gc_lastrun', 0);
- $now = time();
- if (($now - $lastRun) < self::CLEANUP_TTL_SEC) {
- return;
- }
- $config->setAppValue('core', 'global_cache_gc_lastrun', $now);
- if (!is_dir($cacheDir)) {
- return;
- }
- $paths = $this->getExpiredPaths($cacheDir, $now);
- array_walk($paths, function($file) {
- if (file_exists($file)) {
- unlink($file);
- }
- });
- }
-}
diff --git a/lib/private/cache/usercache.php b/lib/private/cache/usercache.php
deleted file mode 100644
index bbf5b7eda69..00000000000
--- a/lib/private/cache/usercache.php
+++ /dev/null
@@ -1,93 +0,0 @@
-<?php
-/**
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Scrutinizer Auto-Fixer <auto-fixer@scrutinizer-ci.com>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- * @author Thomas Tanghus <thomas@tanghus.net>
- *
- * @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\Cache;
-
-/**
- * This interface defines method for accessing the file based user cache.
- */
-class UserCache implements \OCP\ICache {
-
- /**
- * @var \OC\Cache\File $userCache
- */
- protected $userCache;
-
- public function __construct() {
- $this->userCache = new File();
- }
-
- /**
- * Get a value from the user cache
- *
- * @param string $key
- * @return mixed
- */
- public function get($key) {
- return $this->userCache->get($key);
- }
-
- /**
- * Set a value in the user cache
- *
- * @param string $key
- * @param string $value
- * @param int $ttl Time To Live in seconds. Defaults to 60*60*24
- * @return bool
- */
- public function set($key, $value, $ttl = 0) {
- if (empty($key)) {
- return false;
- }
- return $this->userCache->set($key, $value, $ttl);
- }
-
- /**
- * Check if a value is set in the user cache
- *
- * @param string $key
- * @return bool
- */
- public function hasKey($key) {
- return $this->userCache->hasKey($key);
- }
-
- /**
- * Remove an item from the user cache
- *
- * @param string $key
- * @return bool
- */
- public function remove($key) {
- return $this->userCache->remove($key);
- }
-
- /**
- * clear the user cache of all entries starting with a prefix
- * @param string $prefix (optional)
- * @return bool
- */
- public function clear($prefix = '') {
- return $this->userCache->clear($prefix);
- }
-}
diff --git a/lib/private/repair.php b/lib/private/repair.php
index 0674207bbee..c690fe4a8cd 100644
--- a/lib/private/repair.php
+++ b/lib/private/repair.php
@@ -32,6 +32,7 @@ use OC\Hooks\Emitter;
use OC\Repair\AssetCache;
use OC\Repair\CleanTags;
use OC\Repair\Collation;
+use OC\Repair\DropOldJobs;
use OC\Repair\SqliteAutoincrement;
use OC\Repair\DropOldTables;
use OC\Repair\FillETags;
@@ -106,6 +107,7 @@ class Repair extends BasicEmitter {
new FillETags(\OC_DB::getConnection()),
new CleanTags(\OC_DB::getConnection()),
new DropOldTables(\OC_DB::getConnection()),
+ new DropOldJobs(\OC::$server->getJobList()),
);
}
diff --git a/lib/private/server.php b/lib/private/server.php
index aea5be5afa6..8113080977f 100644
--- a/lib/private/server.php
+++ b/lib/private/server.php
@@ -38,7 +38,6 @@ use bantu\IniGetWrapper\IniGetWrapper;
use OC\AppFramework\Http\Request;
use OC\AppFramework\Db\Db;
use OC\AppFramework\Utility\SimpleContainer;
-use OC\Cache\UserCache;
use OC\Command\AsyncBus;
use OC\Diagnostics\NullQueryLogger;
use OC\Diagnostics\EventLogger;
@@ -47,6 +46,7 @@ use OC\Lock\MemcacheLockingProvider;
use OC\Lock\NoopLockingProvider;
use OC\Mail\Mailer;
use OC\Memcache\ArrayCache;
+use OC\Memcache\Null as NullCache;
use OC\Http\Client\ClientService;
use OC\Security\CertificateManager;
use OC\Files\Node\Root;
@@ -219,8 +219,8 @@ class Server extends SimpleContainer implements IServerContainer {
$this->registerService('AppHelper', function ($c) {
return new \OC\AppHelper();
});
- $this->registerService('UserCache', function ($c) {
- return new UserCache();
+ $this->registerService('NullCache', function ($c) {
+ return new NullCache();
});
$this->registerService('MemCacheFactory', function (Server $c) {
$config = $c->getConfig();
@@ -661,12 +661,14 @@ class Server extends SimpleContainer implements IServerContainer {
}
/**
- * Returns an ICache instance
+ * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
+ * getMemCacheFactory() instead.
*
* @return \OCP\ICache
+ * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
*/
public function getCache() {
- return $this->query('UserCache');
+ return $this->query('NullCache');
}
/**
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],
+ ];
+ }
+
+
+}