[Pkg-owncloud-commits] [owncloud] 06/457: remove file cache classes and its tests

David Prévot taffit at moszumanska.debian.org
Sun Jun 28 20:05:16 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch stable8
in repository owncloud.

commit 3de7f58321462601755cac3745dca5c25edc6f2b
Author: Arthur Schiwon <blizzz at owncloud.com>
Date:   Fri May 8 14:05:54 2015 +0200

    remove file cache classes and its tests
---
 lib/private/cache.php              | 129 ---------------------------
 lib/private/cache/broker.php       |  80 -----------------
 lib/private/cache/file.php         | 174 -------------------------------------
 lib/private/cache/fileglobal.php   | 107 -----------------------
 lib/private/cache/fileglobalgc.php |  80 -----------------
 lib/private/cache/usercache.php    |  93 --------------------
 tests/lib/cache/file.php           |  78 -----------------
 tests/lib/cache/fileglobalgc.php   | 107 -----------------------
 tests/lib/cache/usercache.php      |  74 ----------------
 9 files changed, 922 deletions(-)

diff --git a/lib/private/cache.php b/lib/private/cache.php
deleted file mode 100644
index 095a1dd..0000000
--- a/lib/private/cache.php
+++ /dev/null
@@ -1,129 +0,0 @@
-<?php
-/**
- * @author Bart Visscher <bartv at thisnet.nl>
- * @author Morris Jobke <hey at morrisjobke.de>
- * @author Robin Appelman <icewind at owncloud.com>
- * @author Thomas Müller <thomas.mueller at tmit.eu>
- * @author Thomas Tanghus <thomas at 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 a52fb22..0000000
--- a/lib/private/cache/broker.php
+++ /dev/null
@@ -1,80 +0,0 @@
-<?php
-/**
- * @author Bart Visscher <bartv at thisnet.nl>
- * @author Morris Jobke <hey at morrisjobke.de>
- * @author Robin Appelman <icewind at owncloud.com>
- * @author Thomas Müller <thomas.mueller at tmit.eu>
- * @author Thomas Tanghus <thomas at 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 c70698e..0000000
--- a/lib/private/cache/file.php
+++ /dev/null
@@ -1,174 +0,0 @@
-<?php
-/**
- * @author Arthur Schiwon <blizzz at owncloud.com>
- * @author Bart Visscher <bartv at thisnet.nl>
- * @author Björn Schießle <schiessle at owncloud.com>
- * @author Jörn Friedrich Dreyer <jfd at butonic.de>
- * @author Michael Gapczynski <GapczynskiM at gmail.com>
- * @author Morris Jobke <hey at morrisjobke.de>
- * @author Robin Appelman <icewind at owncloud.com>
- * @author Robin McCorkell <rmccorkell at karoshi.org.uk>
- * @author Thomas Müller <thomas.mueller at tmit.eu>
- * @author Thomas Tanghus <thomas at tanghus.net>
- * @author Vincent Petry <pvince81 at 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 b808c0d..0000000
--- a/lib/private/cache/fileglobal.php
+++ /dev/null
@@ -1,107 +0,0 @@
-<?php
-/**
- * @author Arthur Schiwon <blizzz at owncloud.com>
- * @author Bart Visscher <bartv at thisnet.nl>
- * @author Jörn Friedrich Dreyer <jfd at butonic.de>
- * @author Morris Jobke <hey at morrisjobke.de>
- * @author Thomas Müller <thomas.mueller at tmit.eu>
- * @author Thomas Tanghus <thomas at 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 0d96628..0000000
--- a/lib/private/cache/fileglobalgc.php
+++ /dev/null
@@ -1,80 +0,0 @@
-<?php
-/**
- * @author Morris Jobke <hey at morrisjobke.de>
- * @author Robin Appelman <icewind at owncloud.com>
- * @author Robin McCorkell <rmccorkell at karoshi.org.uk>
- * @author Thomas Tanghus <thomas at 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 bbf5b7e..0000000
--- a/lib/private/cache/usercache.php
+++ /dev/null
@@ -1,93 +0,0 @@
-<?php
-/**
- * @author Morris Jobke <hey at morrisjobke.de>
- * @author Scrutinizer Auto-Fixer <auto-fixer at scrutinizer-ci.com>
- * @author Thomas Müller <thomas.mueller at tmit.eu>
- * @author Thomas Tanghus <thomas at 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/tests/lib/cache/file.php b/tests/lib/cache/file.php
deleted file mode 100644
index 153cb19..0000000
--- a/tests/lib/cache/file.php
+++ /dev/null
@@ -1,78 +0,0 @@
-<?php
-/**
-* ownCloud
-*
-* @author Robin Appelman
-* @copyright 2012 Robin Appelman icewind at owncloud.com
-*
-* This library is free software; you can redistribute it and/or
-* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
-* License as published by the Free Software Foundation; either
-* version 3 of the License, or any later version.
-*
-* This library 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 library.  If not, see <http://www.gnu.org/licenses/>.
-*
-*/
-
-namespace Test\Cache;
-
-class FileCache extends \Test_Cache {
-	/** @var string */
-	private $user;
-	/** @var string */
-	private $datadir;
-	/** @var \OC\Files\Storage\Storage */
-	private $storage;
-
-	function skip() {
-		//$this->skipUnless(OC_User::isLoggedIn());
-	}
-
-	protected function setUp() {
-		parent::setUp();
-
-		//clear all proxies and hooks so we can do clean testing
-		\OC_Hook::clear('OC_Filesystem');
-
-		//set up temporary storage
-		$this->storage = \OC\Files\Filesystem::getStorage('/');
-		\OC\Files\Filesystem::clearMounts();
-		$storage = new \OC\Files\Storage\Temporary(array());
-		\OC\Files\Filesystem::mount($storage,array(),'/');
-		$datadir = str_replace('local::', '', $storage->getId());
-		$this->datadir = \OC_Config::getValue('cachedirectory', \OC::$SERVERROOT.'/data/cache');
-		\OC_Config::setValue('cachedirectory', $datadir);
-
-		\OC_User::clearBackends();
-		\OC_User::useBackend(new \OC_User_Dummy());
-		
-		//login
-		\OC_User::createUser('test', 'test');
-		
-		$this->user = \OC_User::getUser();
-		\OC_User::setUserId('test');
-
-		//set up the users dir
-		$rootView = new \OC\Files\View('');
-		$rootView->mkdir('/test');
-		
-		$this->instance=new \OC\Cache\File();
-	}
-
-	protected function tearDown() {
-		\OC_User::setUserId($this->user);
-		\OC_Config::setValue('cachedirectory', $this->datadir);
-
-		// Restore the original mount point
-		\OC\Files\Filesystem::clearMounts();
-		\OC\Files\Filesystem::mount($this->storage, array(), '/');
-
-		parent::tearDown();
-	}
-}
diff --git a/tests/lib/cache/fileglobalgc.php b/tests/lib/cache/fileglobalgc.php
deleted file mode 100644
index 4f03253..0000000
--- a/tests/lib/cache/fileglobalgc.php
+++ /dev/null
@@ -1,107 +0,0 @@
-<?php
-/**
- * ownCloud
- *
- * @author Robin Appelman
- * @copyright 2012 Robin Appelman icewind at owncloud.com
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library 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 library.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-namespace Test\Cache;
-
-use Test\TestCase;
-
-class FileGlobalGC extends TestCase {
-	/**
-	 * @var string
-	 */
-	private $cacheDir;
-
-	/**
-	 * @var \OC\Cache\FileGlobalGC
-	 */
-	private $gc;
-
-	public function setUp() {
-		$this->cacheDir = \OC::$server->getTempManager()->getTemporaryFolder();
-		$this->gc = new \OC\Cache\FileGlobalGC();
-	}
-
-	private function addCacheFile($name, $expire) {
-		file_put_contents($this->cacheDir . $name, 'foo');
-		touch($this->cacheDir . $name, $expire);
-	}
-
-	public function testGetExpiredEmpty() {
-		$this->assertEquals([], $this->gc->getExpiredPaths($this->cacheDir, time()));
-	}
-
-	public function testGetExpiredNone() {
-		$time = time();
-		$this->addCacheFile('foo', $time + 10);
-		$this->assertEquals([], $this->gc->getExpiredPaths($this->cacheDir, $time));
-	}
-
-	public function testGetExpired() {
-		$time = time();
-		$this->addCacheFile('foo', $time + 10);
-		$this->addCacheFile('bar', $time);
-		$this->addCacheFile('bar2', $time - 10);
-		$this->addCacheFile('asd', $time - 100);
-		$this->assertEquals([$this->cacheDir . 'asd', $this->cacheDir . 'bar2'], $this->gc->getExpiredPaths($this->cacheDir, $time));
-	}
-
-	public function testGetExpiredDirectory() {
-		$time = time();
-		$this->addCacheFile('foo', $time - 10);
-		mkdir($this->cacheDir . 'asd');
-		$this->assertEquals([$this->cacheDir . 'foo'], $this->gc->getExpiredPaths($this->cacheDir, $time));
-	}
-
-	public function testGcUnlink() {
-		$time = time();
-		$this->addCacheFile('foo', $time - 10);
-		$this->addCacheFile('bar', $time - 10);
-		$this->addCacheFile('asd', $time + 10);
-
-		$config = $this->getMock('\OCP\IConfig');
-		$config->expects($this->once())
-			->method('getAppValue')
-			->with('core', 'global_cache_gc_lastrun', 0)
-			->willReturn($time - \OC\Cache\FileGlobalGC::CLEANUP_TTL_SEC - 1);
-		$config->expects($this->once())
-			->method('setAppValue');
-
-		$this->gc->gc($config, $this->cacheDir);
-		$this->assertFileNotExists($this->cacheDir . 'foo');
-		$this->assertFileNotExists($this->cacheDir . 'bar');
-		$this->assertFileExists($this->cacheDir . 'asd');
-	}
-
-	public function testGcLastRun() {
-		$time = time();
-
-		$config = $this->getMock('\OCP\IConfig');
-		$config->expects($this->once())
-			->method('getAppValue')
-			->with('core', 'global_cache_gc_lastrun', 0)
-			->willReturn($time);
-		$config->expects($this->never())
-			->method('setAppValue');
-
-		$this->gc->gc($config, $this->cacheDir);
-	}
-}
diff --git a/tests/lib/cache/usercache.php b/tests/lib/cache/usercache.php
deleted file mode 100644
index 26a9158..0000000
--- a/tests/lib/cache/usercache.php
+++ /dev/null
@@ -1,74 +0,0 @@
-<?php
-/**
-* ownCloud
-*
-* @author Robin Appelman
-* @copyright 2012 Robin Appelman icewind at owncloud.com
-*
-* This library is free software; you can redistribute it and/or
-* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
-* License as published by the Free Software Foundation; either
-* version 3 of the License, or any later version.
-*
-* This library 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 library.  If not, see <http://www.gnu.org/licenses/>.
-*
-*/
-
-namespace Test\Cache;
-
-class UserCache extends \Test_Cache {
-	/** @var string */
-	private $user;
-	/** @var string */
-	private $datadir;
-	/** @var \OC\Files\Storage\Storage */
-	private $storage;
-
-	protected function setUp() {
-		parent::setUp();
-
-		//clear all proxies and hooks so we can do clean testing
-		\OC_Hook::clear('OC_Filesystem');
-
-		//set up temporary storage
-		$this->storage = \OC\Files\Filesystem::getStorage('/');
-		\OC\Files\Filesystem::clearMounts();
-		$storage = new \OC\Files\Storage\Temporary(array());
-		\OC\Files\Filesystem::mount($storage,array(),'/');
-		$datadir = str_replace('local::', '', $storage->getId());
-		$this->datadir = \OC_Config::getValue('cachedirectory', \OC::$SERVERROOT.'/data/cache');
-		\OC_Config::setValue('cachedirectory', $datadir);
-
-		\OC_User::clearBackends();
-		\OC_User::useBackend(new \OC_User_Dummy());
-		
-		//login
-		\OC_User::createUser('test', 'test');
-		
-		$this->user = \OC_User::getUser();
-		\OC_User::setUserId('test');
-
-		//set up the users dir
-		$rootView=new \OC\Files\View('');
-		$rootView->mkdir('/test');
-		
-		$this->instance=new \OC\Cache\UserCache();
-	}
-
-	protected function tearDown() {
-		\OC_User::setUserId($this->user);
-		\OC_Config::setValue('cachedirectory', $this->datadir);
-
-		// Restore the original mount point
-		\OC\Files\Filesystem::clearMounts();
-		\OC\Files\Filesystem::mount($this->storage, array(), '/');
-
-		parent::tearDown();
-	}
-}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list