]> source.dussan.org Git - nextcloud-server.git/commitdiff
return both, count and result if the operation succeeded or failed. Maybe in some...
authorBjörn Schießle <schiessle@owncloud.com>
Fri, 22 Feb 2013 15:43:11 +0000 (16:43 +0100)
committerBjörn Schießle <schiessle@owncloud.com>
Fri, 22 Feb 2013 15:43:11 +0000 (16:43 +0100)
apps/files_sharing/lib/sharedstorage.php
lib/files/storage/common.php
lib/files/view.php
lib/helper.php
lib/public/files.php

index 65812b7e2fdeeb2b579f941688d359b9cfe8860c..e920329ae4927252fb412722ae2972c8d0ef1aa0 100644 (file)
@@ -314,7 +314,8 @@ class Shared extends \OC\Files\Storage\Common {
                if ($this->isCreatable(dirname($path2))) {
                        $source = $this->fopen($path1, 'r');
                        $target = $this->fopen($path2, 'w');
-                       return \OC_Helper::streamCopy($source, $target);
+                       list ($count, $result) = \OC_Helper::streamCopy($source, $target);
+                       return $result;
                }
                return false;
        }
index 4e7a73e5d4acb0b55be1aae625023079adc7abd5..fd9ae844a8e518b9bdc3e4300f27967f1fa5f7b3 100644 (file)
@@ -97,8 +97,8 @@ abstract class Common implements \OC\Files\Storage\Storage {
        public function copy($path1, $path2) {
                $source=$this->fopen($path1, 'r');
                $target=$this->fopen($path2, 'w');
-               $count=\OC_Helper::streamCopy($source, $target);
-               return $count>0;
+               list($count, $result) = \OC_Helper::streamCopy($source, $target);
+               return $result;
        }
 
        /**
index 11edbadab9bc8b4c019634b32feaa96a8ec7e7da..f48d0c8b225153b2039421e515bf0dfa184122c8 100644 (file)
@@ -285,7 +285,7 @@ class View {
                                }
                                $target = $this->fopen($path, 'w');
                                if ($target) {
-                                       $count = \OC_Helper::streamCopy($data, $target);
+                                       list ($count, $result) = \OC_Helper::streamCopy($data, $target);
                                        fclose($target);
                                        fclose($data);
                                        if ($this->fakeRoot == Filesystem::getRoot()) {
@@ -303,7 +303,7 @@ class View {
                                                );
                                        }
                                        \OC_FileProxy::runPostProxies('file_put_contents', $absolutePath, $count);
-                                       return $count > 0;
+                                       return $result;
                                } else {
                                        return false;
                                }
@@ -361,7 +361,7 @@ class View {
                                } else {
                                        $source = $this->fopen($path1 . $postFix1, 'r');
                                        $target = $this->fopen($path2 . $postFix2, 'w');
-                                       $result = \OC_Helper::streamCopy($source, $target);
+                                       list($count, $result) = \OC_Helper::streamCopy($source, $target);
                                        list($storage1, $internalPath1) = Filesystem::resolvePath($absolutePath1 . $postFix1);
                                        $storage1->unlink($internalPath1);
                                }
@@ -443,7 +443,7 @@ class View {
                                } else {
                                        $source = $this->fopen($path1 . $postFix1, 'r');
                                        $target = $this->fopen($path2 . $postFix2, 'w');
-                                       $result = \OC_Helper::streamCopy($source, $target);
+                                       list($count, $result) = \OC_Helper::streamCopy($source, $target);
                                }
                                if ($this->fakeRoot == Filesystem::getRoot()) {
                                        \OC_Hook::emit(
index 2c9cd36b1996c8f2045036c6a94afe5f7340059a..7420a79eb2db61c345301c2777a60aec333b5a2f 100644 (file)
@@ -513,13 +513,16 @@ class OC_Helper {
                if(!$source or !$target) {
                        return false;
                }
-               $result=true;
+               $result = true;
+               $count = 0;
                while(!feof($source)) {
-                       if (fwrite($target, fread($source, 8192)) === false) {
+                       if ($c = fwrite($target, fread($source, 8192)) === false) {
                                $result = false;
+                       } else {
+                               $count += $c;
                        }
                }
-               return $result;
+               return array($count, $result);
        }
 
        /**
index c2945b200e85d80e09204071ae82ab648d077985..700bf574537fb6046743b8680c9152a07f8b9c3c 100644 (file)
@@ -62,7 +62,8 @@ class Files {
         * @return int the number of bytes copied
         */
        public static function streamCopy( $source, $target ) {
-               return(\OC_Helper::streamCopy( $source, $target ));
+               list($count, $result) = \OC_Helper::streamCopy( $source, $target );
+               return $count;
        }
 
        /**