Skip to content

Commit

Permalink
Add debug lines to SMB.php
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-davis committed Apr 18, 2023
1 parent 73a5c7e commit 417f95b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion apps/files_external/lib/Lib/Storage/SMB.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,11 @@ public function rename($source, $target) {
if ($result) {
$this->removeFromCache($buildSource);
$this->removeFromCache($buildTarget);
} else {
echo "rename AlreadyExistsException unlink passed but next rename failed\n";
}
} else {
echo "rename AlreadyExistsException unlink failed\n";
$result = false;
}
} catch (ConnectException $e) {
Expand All @@ -326,7 +329,9 @@ public function rename($source, $target) {
} catch (Exception $e) {
$this->swallow(__FUNCTION__, $e);
// Icewind\SMB\Exception\Exception, not a plain exception
if ($e->getCode() === 22) {
$code = $e->getCode();
$message = $e->getMessage();
if ($code === 22) {
// some servers seem to return an error code 22 instead of the expected AlreadyExistException
if ($this->unlink($target)) {
$result = $this->share->rename($buildSource, $buildTarget);
Expand All @@ -335,12 +340,17 @@ public function rename($source, $target) {
$this->removeFromCache($buildTarget);
}
} else {
echo "rename Exception unlink failed code $code message '$message'\n";
$result = false;
}
} else {
echo "rename Exception (1) code $code message '$message'\n";
$result = false;
}
} catch (\Exception $e) {
$message = $e->getMessage();
$code = $e->getCode();
echo "rename Exception (2) code $code message '$message'\n";
$this->swallow(__FUNCTION__, $e);
$result = false;
}
Expand Down

0 comments on commit 417f95b

Please sign in to comment.