From 26954896899f58fb20df6962957eb3ea9e6d7ea2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Pablo=20Villaf=C3=A1=C3=B1ez?= Date: Tue, 14 Nov 2017 13:42:42 +0100 Subject: [PATCH 1/2] Consider error 22 as an AlreadyExistsException --- apps/files_external/lib/Lib/Storage/SMB.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/apps/files_external/lib/Lib/Storage/SMB.php b/apps/files_external/lib/Lib/Storage/SMB.php index e0688a345a60..c32ec91eb4a4 100644 --- a/apps/files_external/lib/Lib/Storage/SMB.php +++ b/apps/files_external/lib/Lib/Storage/SMB.php @@ -266,6 +266,17 @@ public function rename($source, $target) { $this->removeFromCache($this->root . $source); $this->removeFromCache($this->root . $target); $this->swallow(__FUNCTION__, $e); + } catch (Exception $e) { + // Icewind\SMB\Exception\Exception, not a plain exception + if ($e->getCode() === 22) { + $this->unlink($target); + $result = $this->share->rename($this->root . $source, $this->root . $target); + $this->removeFromCache($this->root . $source); + $this->removeFromCache($this->root . $target); + } else { + $result = false; + } + $this->swallow(__FUNCTION__, $e); } catch (\Exception $e) { $this->swallow(__FUNCTION__, $e); $result = false; From beb0bfc62ec89181ef2b23731ab697a9c1584b4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Pablo=20Villaf=C3=A1=C3=B1ez?= Date: Tue, 14 Nov 2017 17:16:18 +0100 Subject: [PATCH 2/2] Reorder swallow for better trace --- apps/files_external/lib/Lib/Storage/SMB.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/files_external/lib/Lib/Storage/SMB.php b/apps/files_external/lib/Lib/Storage/SMB.php index c32ec91eb4a4..7d0df7d7922c 100644 --- a/apps/files_external/lib/Lib/Storage/SMB.php +++ b/apps/files_external/lib/Lib/Storage/SMB.php @@ -261,12 +261,13 @@ public function rename($source, $target) { $this->removeFromCache($this->root . $source); $this->removeFromCache($this->root . $target); } catch (AlreadyExistsException $e) { + $this->swallow(__FUNCTION__, $e); $this->unlink($target); $result = $this->share->rename($this->root . $source, $this->root . $target); $this->removeFromCache($this->root . $source); $this->removeFromCache($this->root . $target); - $this->swallow(__FUNCTION__, $e); } catch (Exception $e) { + $this->swallow(__FUNCTION__, $e); // Icewind\SMB\Exception\Exception, not a plain exception if ($e->getCode() === 22) { $this->unlink($target); @@ -276,7 +277,6 @@ public function rename($source, $target) { } else { $result = false; } - $this->swallow(__FUNCTION__, $e); } catch (\Exception $e) { $this->swallow(__FUNCTION__, $e); $result = false;