From 5b949596867c986916568e5bea2003e04102aa71 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= <schiessle@owncloud.com>
Date: Fri, 22 Feb 2013 14:56:50 +0100
Subject: [PATCH] using the number of writen bytes as indicator if streamCopy()
 was successfully. Instead check if fwrite returns the number of bytes or
 false

---
 lib/files/view.php | 3 +--
 lib/helper.php     | 8 +++++---
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/lib/files/view.php b/lib/files/view.php
index 9ac08c9808..11edbadab9 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 add5c66e7b..2c9cd36b19 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;
 	}
 
 	/**
-- 
GitLab