From 9ead7c4776bd512c2a50ab917b99dcdc37e8db68 Mon Sep 17 00:00:00 2001
From: Michael Gapczynski <mtgap@owncloud.com>
Date: Sat, 13 Apr 2013 15:04:46 -0400
Subject: [PATCH] Don't unlink old renamed file if stream copy failed

---
 lib/files/view.php | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/files/view.php b/lib/files/view.php
index b0e8291935..d2d1a99818 100644
--- a/lib/files/view.php
+++ b/lib/files/view.php
@@ -370,7 +370,9 @@ class View {
 					$target = $this->fopen($path2 . $postFix2, 'w');
 					list($count, $result) = \OC_Helper::streamCopy($source, $target);
 					list($storage1, $internalPath1) = Filesystem::resolvePath($absolutePath1 . $postFix1);
-					$storage1->unlink($internalPath1);
+					if ($result !== false) {
+						$storage1->unlink($internalPath1);
+					}
 				}
 				if ($this->fakeRoot == Filesystem::getRoot() && $result !== false) {
 					\OC_Hook::emit(
-- 
GitLab