From a59612752e3b2829516833ea5b189df63ff49cd0 Mon Sep 17 00:00:00 2001
From: Robin Appelman <icewind@owncloud.com>
Date: Wed, 28 Jan 2015 15:16:55 +0100
Subject: [PATCH] Fix trash error when deleting files with the same name at the
 same time (happens in unit tests)

---
 apps/files_trashbin/lib/trashbin.php | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/apps/files_trashbin/lib/trashbin.php b/apps/files_trashbin/lib/trashbin.php
index 4086bb1216..0576be66b4 100644
--- a/apps/files_trashbin/lib/trashbin.php
+++ b/apps/files_trashbin/lib/trashbin.php
@@ -167,6 +167,9 @@ class Trashbin {
 		$trashPath = '/files_trashbin/files/' . $filename . '.d' . $timestamp;
 		try {
 			$sizeOfAddedFiles = $view->filesize('/files/' . $file_path);
+			if ($view->file_exists($trashPath)) {
+				$view->unlink($trashPath);
+			}
 			$view->rename('/files/' . $file_path, $trashPath);
 		} catch (\OCA\Files_Trashbin\Exceptions\CopyRecursiveException $e) {
 			$sizeOfAddedFiles = false;
-- 
GitLab