]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix filesystem hash, no longer using basicOperation()
authorMichael Gapczynski <mtgap@owncloud.com>
Wed, 25 Jul 2012 20:54:46 +0000 (16:54 -0400)
committerMichael Gapczynski <mtgap@owncloud.com>
Mon, 30 Jul 2012 14:07:19 +0000 (10:07 -0400)
Conflicts:
lib/filesystemview.php

apps/files_sharing/sharedstorage.php
lib/filestorage.php
lib/filestorage/common.php
lib/filestorage/local.php
lib/filesystem.php
lib/filesystemview.php

index d46a7d4e70abd1e6881fec6c5a7d2d986ecc4361..41af077b5a93539afcceeeb14fff50b54d57d405 100644 (file)
@@ -456,7 +456,7 @@ class OC_Filestorage_Shared extends OC_Filestorage {
                }
        }
        
-       public function hash($type, $path, $raw) {
+       public function hash($type, $path, $raw = false) {
                $source = $this->getSource($path);
                if ($source) {
                        $storage = OC_Filesystem::getStorage($source);
index fd6497b9478387a6746e655dedf0d87af92de7ab..1a33d30463058a695bbe2b683e032446b3bdddfe 100644 (file)
@@ -45,7 +45,7 @@ abstract class OC_Filestorage{
        abstract public function copy($path1,$path2);
        abstract public function fopen($path,$mode);
        abstract public function getMimeType($path);
-       abstract public function hash($type,$path,$raw);
+       abstract public function hash($type,$path,$raw = false);
        abstract public function free_space($path);
        abstract public function search($query);
        abstract public function touch($path, $mtime=null);
index f0bfc064cb581ae9ed07dcbf64babf7f925eaff8..0d3e2c25fd638c35ece93f5885c4d1d2f5f7bd73 100644 (file)
@@ -110,7 +110,7 @@ abstract class OC_Filestorage_Common extends OC_Filestorage {
                unlink($tmpFile);
                return $mime;
        }
-       public function hash($type,$path,$raw){
+       public function hash($type,$path,$raw = false){
                $tmpFile=$this->getLocalFile();
                $hash=hash($type,$tmpFile,$raw);
                unlink($tmpFile);
index ea9a907026358d69b31e7e243b0208d01c87317e..1f3fd2e92498b9ae4290271c672f2ea4ca1d2ad1 100644 (file)
@@ -157,7 +157,7 @@ class OC_Filestorage_Local extends OC_Filestorage{
                return $return;
        }
 
-       public function hash($type,$path,$raw){
+       public function hash($type,$path,$raw = false){
                return hash_file($type,$this->datadir.$path,$raw);
        }
 
index 813590b00bb3e41ce3b586c55b1f7df893e1d1c0..2c7df5daa3cf72dd298af1b77ec5e0cded9b3248 100644 (file)
@@ -458,8 +458,8 @@ class OC_Filesystem{
        static public function getMimeType($path){
                return self::$defaultInstance->getMimeType($path);
        }
-       static public function hash($type,$path){
-               return self::$defaultInstance->hash($type,$path);
+       static public function hash($type,$path, $raw = false){
+               return self::$defaultInstance->hash($type,$path, $raw);
        }
        
        static public function free_space($path='/'){
index c09f1de546a68cfaf084014139837dcb52620bbb..f147cf5b244f55185968417053a74880370e1de9 100644 (file)
@@ -366,8 +366,27 @@ class OC_FilesystemView {
        public function getMimeType($path){
                return $this->basicOperation('getMimeType',$path);
        }
-       public function hash($type,$path){
-               return $this->basicOperation('hash',$path,array('read'));
+       public function hash($type, $path, $raw = false) {
+               $absolutePath = $this->getAbsolutePath($path);
+               if (OC_FileProxy::runPreProxies('hash', $absolutePath) && OC_Filesystem::isValidPath($path)) {
+                       $path = $this->getRelativePath($absolutePath);
+                       if ($path == null) {
+                               return false;
+                       }
+                       if (OC_Filesystem::$loaded && $this->fakeRoot == OC_Filesystem::getRoot()) {
+                               OC_Hook::emit(
+                                       OC_Filesystem::CLASSNAME,
+                                       OC_Filesystem::signal_read,
+                                       array( OC_Filesystem::signal_param_path => $path)
+                               );
+                       }
+                       if ($storage = $this->getStorage($path)) {
+                               $result = $storage->hash($type, $this->getInternalPath($path), $raw);
+                               $result = OC_FileProxy::runPostProxies('hash', $absolutePath, $result);
+                               return $result;
+                       }
+               }
+               return null;
        }
 
        public function free_space($path='/'){