From 3b08b3fad4729549a01679ca2c9e8d33234a58bf Mon Sep 17 00:00:00 2001
From: Robin Appelman <icewind@owncloud.com>
Date: Fri, 1 Aug 2014 14:57:43 +0200
Subject: [PATCH] Fix amazon s3 rename overwrite

---
 apps/files_external/lib/amazons3.php | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/apps/files_external/lib/amazons3.php b/apps/files_external/lib/amazons3.php
index 38e6371f5b9..d9e3ef05265 100644
--- a/apps/files_external/lib/amazons3.php
+++ b/apps/files_external/lib/amazons3.php
@@ -511,6 +511,12 @@ class AmazonS3 extends \OC\Files\Storage\Common {
 		$path2 = $this->normalizePath($path2);
 
 		if ($this->is_file($path1)) {
+			if ($this->is_dir($path2)) {
+				$this->rmdir($path2);
+			} else if ($this->file_exists($path2)) {
+				$this->unlink($path2);
+			}
+
 			if ($this->copy($path1, $path2) === false) {
 				return false;
 			}
@@ -520,8 +526,10 @@ class AmazonS3 extends \OC\Files\Storage\Common {
 				return false;
 			}
 		} else {
-			if ($this->file_exists($path2)) {
-				return false;
+			if ($this->is_dir($path2)) {
+				$this->rmdir($path2);
+			} else if ($this->file_exists($path2)) {
+				$this->unlink($path2);
 			}
 
 			if ($this->copy($path1, $path2) === false) {
-- 
GitLab