]> source.dussan.org Git - nextcloud-server.git/commitdiff
backport home storage to stable5
authorJörn Friedrich Dreyer <jfd@butonic.de>
Wed, 30 Oct 2013 15:52:17 +0000 (16:52 +0100)
committerJörn Friedrich Dreyer <jfd@butonic.de>
Wed, 30 Oct 2013 15:52:17 +0000 (16:52 +0100)
lib/files/cache/cache.php
lib/files/filesystem.php
lib/files/storage/home.php [new file with mode: 0644]

index 1265454400c3ae21e616c7c2a4a9d186f6214a73..528fa7116bfb33c4164855f9fea4436283b455a5 100644 (file)
@@ -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
         *
index 4b445588a65b285f46866459446aaf26c6a87c94..14ca882982ef743ff76a6667a9c2392ca1b59331 100644 (file)
@@ -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 (file)
index 0000000..9521730
--- /dev/null
@@ -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