summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2018-06-27 15:33:51 +0200
committerRobin Appelman <robin@icewind.nl>2018-07-11 16:38:35 +0200
commit4f9aac4002affcb6e65085f723dd11ea0d1a6323 (patch)
tree18f3be2fccf84cb78b92409f1b7af7fee5fda1b5
parente8af003b410481b00a43f00ad6ed9d83956a4746 (diff)
downloadnextcloud-server-4f9aac4002affcb6e65085f723dd11ea0d1a6323.tar.gz
nextcloud-server-4f9aac4002affcb6e65085f723dd11ea0d1a6323.zip
also retry rename operation on InvalidArgumentException
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r--apps/files_external/lib/Lib/Storage/SMB.php20
1 files changed, 17 insertions, 3 deletions
diff --git a/apps/files_external/lib/Lib/Storage/SMB.php b/apps/files_external/lib/Lib/Storage/SMB.php
index 8fa654ffbbf..6c6fcccfc67 100644
--- a/apps/files_external/lib/Lib/Storage/SMB.php
+++ b/apps/files_external/lib/Lib/Storage/SMB.php
@@ -38,6 +38,7 @@ use Icewind\SMB\Exception\AlreadyExistsException;
use Icewind\SMB\Exception\ConnectException;
use Icewind\SMB\Exception\Exception;
use Icewind\SMB\Exception\ForbiddenException;
+use Icewind\SMB\Exception\InvalidArgumentException;
use Icewind\SMB\Exception\NotFoundException;
use Icewind\SMB\IFileInfo;
use Icewind\SMB\NativeServer;
@@ -195,7 +196,7 @@ class SMB extends Common implements INotifyStorage {
* @param string $target the new name of the path
* @return bool true if the rename is successful, false otherwise
*/
- public function rename($source, $target) {
+ public function rename($source, $target, $retry = true) {
if ($this->isRootDir($source) || $this->isRootDir($target)) {
return false;
}
@@ -205,8 +206,21 @@ class SMB extends Common implements INotifyStorage {
try {
$result = $this->share->rename($absoluteSource, $absoluteTarget);
} catch (AlreadyExistsException $e) {
- $this->remove($target);
- $result = $this->share->rename($absoluteSource, $absoluteTarget);
+ if ($retry) {
+ $this->remove($target);
+ $result = $this->share->rename($absoluteSource, $absoluteTarget, false);
+ } else {
+ \OC::$server->getLogger()->logException($e, ['level' => ILogger::WARN]);
+ return false;
+ }
+ } catch (InvalidArgumentException $e) {
+ if ($retry) {
+ $this->remove($target);
+ $result = $this->share->rename($absoluteSource, $absoluteTarget, false);
+ } else {
+ \OC::$server->getLogger()->logException($e, ['level' => ILogger::WARN]);
+ return false;
+ }
} catch (\Exception $e) {
\OC::$server->getLogger()->logException($e, ['level' => Util::WARN]);
return false;