Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2013-10-31 14:32:23 +0400
committerThomas Müller <thomas.mueller@tmit.eu>2013-10-31 14:32:23 +0400
commit640a1f28feb18acac8126f7eb2004ac85c416faf (patch)
treeb145276dd7e1795c745c69d1bbd815de41ed79b9 /lib
parent3b1c365c829b7d37a383fd9085ae66133d754da7 (diff)
parent9d259306a7ede9aef871081713fd9d42bfbbd461 (diff)
Merge pull request #5630 from owncloud/backport_home_storage_stable5
backport home storage to stable5
Diffstat (limited to 'lib')
-rw-r--r--lib/files/cache/cache.php13
-rw-r--r--lib/files/filesystem.php6
-rw-r--r--lib/files/storage/home.php31
3 files changed, 49 insertions, 1 deletions
diff --git a/lib/files/cache/cache.php b/lib/files/cache/cache.php
index 1265454400c..528fa7116bf 100644
--- a/lib/files/cache/cache.php
+++ b/lib/files/cache/cache.php
@@ -67,6 +67,19 @@ class Cache {
return $this->numericId;
}
+ public static function storageExists($storageId) {
+ if (strlen($storageId) > 64) {
+ $storageId = md5($storageId);
+ }
+ $query = \OC_DB::prepare('SELECT `numeric_id` FROM `*PREFIX*storages` WHERE `id` = ?');
+ $result = $query->execute(array($storageId));
+ if ($row = $result->fetchRow()) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
/**
* normalize mimetypes
*
diff --git a/lib/files/filesystem.php b/lib/files/filesystem.php
index 4b445588a65..14ca882982e 100644
--- a/lib/files/filesystem.php
+++ b/lib/files/filesystem.php
@@ -221,7 +221,11 @@ class Filesystem {
$parser = new \OC\ArrayParser();
$root = \OC_User::getHome($user);
- self::mount('\OC\Files\Storage\Local', array('datadir' => $root), $user);
+ if (\OC\Files\Cache\Cache::storageExists('local::' . $root . '/') or is_null($user)) {
+ self::mount('\OC\Files\Storage\Local', array('datadir' => $root), $user);
+ } else {
+ self::mount('\OC\Files\Storage\Home', array('user' => $user, 'datadir' => $root), $user);
+ }
$datadir = \OC_Config::getValue("datadirectory", \OC::$SERVERROOT . "/data");
//move config file to it's new position
diff --git a/lib/files/storage/home.php b/lib/files/storage/home.php
new file mode 100644
index 00000000000..9521730765e
--- /dev/null
+++ b/lib/files/storage/home.php
@@ -0,0 +1,31 @@
+<?php
+/**
+ * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OC\Files\Storage;
+
+/**
+ * Specialized version of Local storage for home directory usage
+ */
+class Home extends Local {
+ /**
+ * @var \OC\User\User $user
+ */
+ protected $user;
+
+ public function __construct($arguments) {
+ $this->user = $arguments['user'];
+ $this->datadir = $arguments['datadir'];
+ if (substr($this->datadir, -1) !== '/') {
+ $this->datadir .= '/';
+ }
+ }
+
+ public function getId() {
+ return 'home::' . $this->user;
+ }
+} \ No newline at end of file