Merge pull request #13893 from owncloud/create-cachedir-on-user
Only make sure the cache directory exists when we use it
This commit is contained in:
commit
82254ad5ef
|
@ -9,11 +9,15 @@
|
||||||
|
|
||||||
namespace OC\Cache;
|
namespace OC\Cache;
|
||||||
|
|
||||||
|
use OC\Files\Filesystem;
|
||||||
|
use OC\Files\View;
|
||||||
|
|
||||||
class File {
|
class File {
|
||||||
protected $storage;
|
protected $storage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the cache storage for the logged in user
|
* Returns the cache storage for the logged in user
|
||||||
|
*
|
||||||
* @return \OC\Files\View cache storage
|
* @return \OC\Files\View cache storage
|
||||||
*/
|
*/
|
||||||
protected function getStorage() {
|
protected function getStorage() {
|
||||||
|
@ -21,8 +25,13 @@ class File {
|
||||||
return $this->storage;
|
return $this->storage;
|
||||||
}
|
}
|
||||||
if (\OC_User::isLoggedIn()) {
|
if (\OC_User::isLoggedIn()) {
|
||||||
\OC\Files\Filesystem::initMountPoints(\OC_User::getUser());
|
$rootView = new View();
|
||||||
$this->storage = new \OC\Files\View('/' . \OC_User::getUser() . '/cache');
|
$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;
|
return $this->storage;
|
||||||
} else {
|
} else {
|
||||||
\OC_Log::write('core', 'Can\'t get cache storage, user not logged in', \OC_Log::ERROR);
|
\OC_Log::write('core', 'Can\'t get cache storage, user not logged in', \OC_Log::ERROR);
|
||||||
|
|
|
@ -395,14 +395,7 @@ class Filesystem {
|
||||||
*/
|
*/
|
||||||
private static function mountCacheDir($user) {
|
private static function mountCacheDir($user) {
|
||||||
$cacheBaseDir = \OC_Config::getValue('cache_path', '');
|
$cacheBaseDir = \OC_Config::getValue('cache_path', '');
|
||||||
if ($cacheBaseDir === '') {
|
if ($cacheBaseDir !== '') {
|
||||||
// use local cache dir relative to the user's home
|
|
||||||
$subdir = 'cache';
|
|
||||||
$view = new \OC\Files\View('/' . $user);
|
|
||||||
if(!$view->file_exists($subdir)) {
|
|
||||||
$view->mkdir($subdir);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$cacheDir = rtrim($cacheBaseDir, '/') . '/' . $user;
|
$cacheDir = rtrim($cacheBaseDir, '/') . '/' . $user;
|
||||||
if (!file_exists($cacheDir)) {
|
if (!file_exists($cacheDir)) {
|
||||||
mkdir($cacheDir, 0770, true);
|
mkdir($cacheDir, 0770, true);
|
||||||
|
|
Loading…
Reference in New Issue