]> source.dussan.org Git - nextcloud-server.git/commitdiff
Introduce Storage::getData() to allow storage implementations more control over the...
authorThomas Müller <thomas.mueller@tmit.eu>
Mon, 20 Apr 2015 12:25:39 +0000 (14:25 +0200)
committerThomas Müller <thomas.mueller@tmit.eu>
Mon, 20 Apr 2015 12:25:39 +0000 (14:25 +0200)
lib/private/files/cache/scanner.php
lib/private/files/storage/common.php
lib/private/files/storage/storage.php
lib/private/files/storage/wrapper/encryption.php
lib/private/files/storage/wrapper/wrapper.php

index 0878b6c60a09766cbdacb1255c9adc9d77daee56..c1ba7c014612e0f70baa4fdedc71454a6efbd48f 100644 (file)
@@ -109,17 +109,10 @@ class Scanner extends BasicEmitter {
                        \OCP\Util::writeLog('OC\Files\Cache\Scanner', "!!! Path '$path' is not accessible or present !!!", \OCP\Util::DEBUG);
                        return null;
                }
-               $data = array();
-               $data['mimetype'] = $this->storage->getMimeType($path);
-               $data['mtime'] = $this->storage->filemtime($path);
-               if ($data['mimetype'] == 'httpd/unix-directory') {
-                       $data['size'] = -1; //unknown
-               } else {
-                       $data['size'] = $this->storage->filesize($path);
-               }
-               $data['etag'] = $this->storage->getETag($path);
-               $data['storage_mtime'] = $data['mtime'];
+
+               $data = $this->storage->getData($path);
                $data['permissions'] = $permissions;
+
                return $data;
        }
 
index 66ed713e22d1d0a99dce1b95b545c01d02be0351..0294fc4b5bea2a3e67344d7c860175d32ae9d74a 100644 (file)
@@ -580,4 +580,21 @@ abstract class Common implements Storage {
                }
                return $result;
        }
+
+       /**
+        * @inheritdoc
+        */
+       public function getData($path) {
+               $data = [];
+               $data['mimetype'] = $this->getMimeType($path);
+               $data['mtime'] = $this->filemtime($path);
+               if ($data['mimetype'] == 'httpd/unix-directory') {
+                       $data['size'] = -1; //unknown
+               } else {
+                       $data['size'] = $this->filesize($path);
+               }
+               $data['etag'] = $this->getETag($path);
+               $data['storage_mtime'] = $data['mtime'];
+               return $data;
+       }
 }
index 4b75fa9da892ad0870e6ab7c7b89734b63100bd2..9fda743afcf5beb9ecc17c3fb5fad3d5564ca533 100644 (file)
@@ -70,4 +70,10 @@ interface Storage extends \OCP\Files\Storage {
         */
        public function getStorageCache();
 
+       /**
+        * @param $path
+        * @return array
+        */
+       public function getData($path);
+
 }
index 01bd861e3a203b35ff492872ddf4394c36d2ee38..df91b7189dc2e75d2e2c240b26ef3d5f3fdc02a2 100644 (file)
@@ -110,6 +110,29 @@ class Encryption extends Wrapper {
                return $this->storage->filesize($path);
        }
 
+       /**
+        * @param $path
+        * @return array
+        */
+       public function getData($path) {
+               $data = $this->storage->getData($path);
+               $fullPath = $this->getFullPath($path);
+
+               if (isset($this->unencryptedSize[$fullPath])) {
+                       $size = $this->unencryptedSize[$fullPath];
+
+                       $data['encrypted'] = true;
+                       $data['size'] = $size;
+               } else {
+                       $info = $this->getCache()->get($path);
+                       if (isset($info['fileid']) && $info['encrypted']) {
+                               $data['encrypted'] = true;
+                               $data['size'] = $info['size'];
+                       }
+               }
+
+               return $data;
+       }
        /**
         * see http://php.net/manual/en/function.file_get_contents.php
         *
index 2552c926e021169b626a53e3bf5c90fd7a125dbe..0bea457c87725cdaf74d1036fa66ec22121b9439 100644 (file)
@@ -525,4 +525,12 @@ class Wrapper implements \OC\Files\Storage\Storage {
        public function moveFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
                return $this->storage->moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
        }
+
+       /**
+        * @param $path
+        * @return array
+        */
+       public function getData($path) {
+               return $this->storage->getData($path);
+       }
 }