From 8755bf1815f0e7a76603026fa2d99c79abc7b273 Mon Sep 17 00:00:00 2001 From: Git'Fellow <12234510+solracsf@users.noreply.github.com> Date: Fri, 15 Nov 2024 19:50:16 +0100 Subject: [PATCH] fix(storage): Try to delete existing target Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com> Add same logic to common storage --- lib/private/Files/Storage/Common.php | 15 +++++++++------ lib/private/Files/Storage/Local.php | 10 ++++++---- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/lib/private/Files/Storage/Common.php b/lib/private/Files/Storage/Common.php index 334ca34294e..8a95e637372 100644 --- a/lib/private/Files/Storage/Common.php +++ b/lib/private/Files/Storage/Common.php @@ -69,13 +69,16 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage, } protected function remove(string $path): bool { - if ($this->is_dir($path)) { - return $this->rmdir($path); - } elseif ($this->is_file($path)) { - return $this->unlink($path); - } else { - return false; + if ($this->file_exists($path)) { + if ($this->is_dir($path)) { + return $this->rmdir($path); + } elseif ($this->is_file($path)) { + return $this->unlink($path); + } else { + return false; + } } + return false; } public function is_dir(string $path): bool { diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php index 6f645c74c11..f06e409cd8f 100644 --- a/lib/private/Files/Storage/Local.php +++ b/lib/private/Files/Storage/Local.php @@ -342,10 +342,12 @@ class Local extends \OC\Files\Storage\Common { return false; } - if ($this->is_dir($target)) { - $this->rmdir($target); - } elseif ($this->is_file($target)) { - $this->unlink($target); + if ($this->file_exists($target)) { + if ($this->is_dir($target)) { + $this->rmdir($target); + } elseif ($this->is_file($target)) { + $this->unlink($target); + } } if ($this->is_dir($source)) { -- 2.39.5