From: Björn Schießle Date: Fri, 22 Feb 2013 13:56:50 +0000 (+0100) Subject: using the number of writen bytes as indicator if streamCopy() was successfully. Inste... X-Git-Tag: v5.0.0beta2~15^2~2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5b949596867c986916568e5bea2003e04102aa71;p=nextcloud-server.git using the number of writen bytes as indicator if streamCopy() was successfully. Instead check if fwrite returns the number of bytes or false --- diff --git a/lib/files/view.php b/lib/files/view.php index 9ac08c98082..11edbadab9b 100644 --- a/lib/files/view.php +++ b/lib/files/view.php @@ -361,10 +361,9 @@ class View { } else { $source = $this->fopen($path1 . $postFix1, 'r'); $target = $this->fopen($path2 . $postFix2, 'w'); - $count = \OC_Helper::streamCopy($source, $target); + $result = \OC_Helper::streamCopy($source, $target); list($storage1, $internalPath1) = Filesystem::resolvePath($absolutePath1 . $postFix1); $storage1->unlink($internalPath1); - $result = $count > 0; } if ($this->fakeRoot == Filesystem::getRoot()) { \OC_Hook::emit( diff --git a/lib/helper.php b/lib/helper.php index add5c66e7be..2c9cd36b199 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -513,11 +513,13 @@ class OC_Helper { if(!$source or !$target) { return false; } - $count=0; + $result=true; while(!feof($source)) { - $count+=fwrite($target, fread($source, 8192)); + if (fwrite($target, fread($source, 8192)) === false) { + $result = false; + } } - return $count; + return $result; } /**