Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions apps/files_external/lib/Lib/Storage/SMB.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
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;
Expand All @@ -52,6 +53,7 @@
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 {
Expand Down Expand Up @@ -195,7 +197,7 @@ protected function formatInfo($info) {
* @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;
}
Expand All @@ -205,8 +207,21 @@ public function rename($source, $target) {
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]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing use

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]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same. ILogger is not defined here.

return false;
}
} catch (\Exception $e) {
\OC::$server->getLogger()->logException($e, ['level' => Util::WARN]);
return false;
Expand Down