Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2018-07-12 10:49:43 +0300
committerGitHub <noreply@github.com>2018-07-12 10:49:43 +0300
commit26395334220052ac11b9c58792b06dcbbf3c2c4c (patch)
tree5ac8e7eb975a2c57d70542913cc4122239684f50
parentdc0fd5f2d2a9627907cac2b100048fea8bf9fd7a (diff)
parent9c5b1852ca15f786903a6e51e5352aa758cf1402 (diff)
Merge pull request #10201 from nextcloud/smb-rename-invalidargument-retry-13
[13] also retry rename operation on InvalidArgumentException
-rw-r--r--apps/files_external/lib/Lib/Storage/SMB.php21
1 files changed, 18 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..40fffce8342 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;
@@ -52,6 +53,7 @@ use OCP\Files\Notify\IChange;
use OCP\Files\Notify\IRenameChange;
use OCP\Files\Storage\INotifyStorage;
use OCP\Files\StorageNotAvailableException;
+use OCP\ILogger;
use OCP\Util;
class SMB extends Common implements INotifyStorage {
@@ -195,7 +197,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 +207,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;