]> source.dussan.org Git - nextcloud-server.git/commitdiff
get shared storage storage id without setting up the storage 820/head
authorRobin Appelman <robin@icewind.nl>
Tue, 9 Aug 2016 13:52:13 +0000 (15:52 +0200)
committerRobin Appelman <robin@icewind.nl>
Tue, 9 Aug 2016 13:52:13 +0000 (15:52 +0200)
apps/files_sharing/lib/SharedMount.php
lib/private/Files/Config/LazyStorageMountInfo.php
lib/private/Files/Mount/MountPoint.php
lib/public/Files/Mount/IMountPoint.php

index 57610db9076cbe4861fcb995707bc79635856361..d160eb24228c547492d69a142c4bf8da8b078576 100644 (file)
@@ -235,4 +235,17 @@ class SharedMount extends MountPoint implements MoveableMount {
        public function getStorageRootId() {
                return $this->getShare()->getNodeId();
        }
+
+       /**
+        * @return int
+        */
+       public function getNumericStorageId() {
+               $builder = \OC::$server->getDatabaseConnection()->getQueryBuilder();
+
+               $query = $builder->select('storage')
+                       ->from('filecache')
+                       ->where($builder->expr()->eq('fileid', $builder->createNamedParameter($this->getShare()->getNodeId())));
+
+               return $query->execute()->fetchColumn();
+       }
 }
index 2e9639f5f084df97fc081577118f206fa862f15e..4df813d57d04c00b850f712020bbcb43e68f0883 100644 (file)
@@ -48,11 +48,7 @@ class LazyStorageMountInfo extends CachedMountInfo {
         */
        public function getStorageId() {
                if (!$this->storageId) {
-                       $storage = $this->mount->getStorage();
-                       if (!$storage) {
-                               return -1;
-                       }
-                       $this->storageId = $storage->getStorageCache()->getNumericId();
+                       $this->storageId = $this->mount->getNumericStorageId();
                }
                return parent::getStorageId();
        }
index d6a6a5565ad6f48d5ecef2a3b7574c8db0f1d6e9..8b8f0574ae0ae4299d81cae3a4acf24e7cf5e337 100644 (file)
@@ -191,6 +191,13 @@ class MountPoint implements IMountPoint {
                return $this->storageId;
        }
 
+       /**
+        * @return int
+        */
+       public function getNumericStorageId() {
+               return $this->getStorage()->getStorageCache()->getNumericId();
+       }
+
        /**
         * @param string $path
         * @return string
index f9a00af7cb59ead81cf206ac6c34ba22b49e2b72..0876d8b11d6e9f9e2ddf1f4043600b802d015e42 100644 (file)
@@ -61,6 +61,14 @@ interface IMountPoint {
         */
        public function getStorageId();
 
+       /**
+        * Get the id of the storages
+        *
+        * @return int
+        * @since 9.1.0
+        */
+       public function getNumericStorageId();
+
        /**
         * Get the path relative to the mountpoint
         *