diff options
author | Vincent Petry <pvince81@owncloud.com> | 2014-03-28 12:08:38 +0100 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2014-03-28 12:08:38 +0100 |
commit | 040f430f0c2c3f1de1d2e24b183c1634c3067adb (patch) | |
tree | 09a5793725aa14c0675c51d2d2d767066b5e2672 /lib/private/files | |
parent | 1e9c5be33d5a7a447168c2e293191e49f8231d21 (diff) | |
parent | e76be308eb8e969b1a4b74d97c2ccb320a986937 (diff) | |
download | nextcloud-server-040f430f0c2c3f1de1d2e24b183c1634c3067adb.tar.gz nextcloud-server-040f430f0c2c3f1de1d2e24b183c1634c3067adb.zip |
Merge pull request #7829 from owncloud/cachefolderlocation
Cache folder is now configurable
Diffstat (limited to 'lib/private/files')
-rw-r--r-- | lib/private/files/filesystem.php | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/private/files/filesystem.php b/lib/private/files/filesystem.php index c31e0c38180..7e27650c557 100644 --- a/lib/private/files/filesystem.php +++ b/lib/private/files/filesystem.php @@ -321,11 +321,36 @@ class Filesystem { self::mount('\OC\Files\Storage\Local', array('datadir' => $root), $user); } + self::mountCacheDir($user); + // Chance to mount for other storages \OC_Hook::emit('OC_Filesystem', 'post_initMountPoints', array('user' => $user, 'user_dir' => $root)); } /** + * Mounts the cache directory + * @param string $user user name + */ + private static function mountCacheDir($user) { + $cacheBaseDir = \OC_Config::getValue('cache_path', ''); + 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; + if (!file_exists($cacheDir)) { + mkdir($cacheDir, 0770, true); + } + // mount external cache dir to "/$user/cache" mount point + self::mount('\OC\Files\Storage\Local', array('datadir' => $cacheDir), '/' . $user . '/cache'); + } + } + + /** * get the default filesystem view * * @return View |