summaryrefslogtreecommitdiffstats
path: root/apps/files_external/lib/Lib
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-07-11 16:25:22 +0200
committerGitHub <noreply@github.com>2018-07-11 16:25:22 +0200
commite35451fd4ea3fcae501c7ae373f82c8a6a3b84ba (patch)
treefdf5233e3b3806ed33fa438fcebdca009f3b330b /apps/files_external/lib/Lib
parente8bd72ebdc540a1bb5e1f8fc1bf43ab32a66cf1d (diff)
parent431710a5aa7192dd739aa2a7f996d9733e004f6a (diff)
downloadnextcloud-server-e35451fd4ea3fcae501c7ae373f82c8a6a3b84ba.tar.gz
nextcloud-server-e35451fd4ea3fcae501c7ae373f82c8a6a3b84ba.zip
Merge pull request #10025 from nextcloud/smb-rename-invalidargument-retry
also retry rename operation on InvalidArgumentException
Diffstat (limited to 'apps/files_external/lib/Lib')
-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 94b4a4e7f34..9c0e6910309 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;
@@ -210,7 +211,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;
}
@@ -220,8 +221,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;