diff options
author | Robin Appelman <robin@icewind.nl> | 2018-06-27 15:33:51 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2018-06-27 15:33:51 +0200 |
commit | 431710a5aa7192dd739aa2a7f996d9733e004f6a (patch) | |
tree | 831f19fa54f922fe507dc3e08cd336f6bff44236 /apps/files_external/lib | |
parent | d9d557a5ef31d63a8807feac1c530c36a077607f (diff) | |
download | nextcloud-server-431710a5aa7192dd739aa2a7f996d9733e004f6a.tar.gz nextcloud-server-431710a5aa7192dd739aa2a7f996d9733e004f6a.zip |
also retry rename operation on InvalidArgumentException
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps/files_external/lib')
-rw-r--r-- | apps/files_external/lib/Lib/Storage/SMB.php | 20 |
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 6213e54dff9..28f0c62fd45 100644 --- a/apps/files_external/lib/Lib/Storage/SMB.php +++ b/apps/files_external/lib/Lib/Storage/SMB.php @@ -39,6 +39,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\Native\NativeServer; @@ -208,7 +209,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; } @@ -218,8 +219,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' => ILogger::WARN]); return false; |