diff options
author | Git'Fellow <12234510+solracsf@users.noreply.github.com> | 2024-11-15 19:50:16 +0100 |
---|---|---|
committer | Git'Fellow <12234510+solracsf@users.noreply.github.com> | 2024-11-20 09:42:33 +0100 |
commit | 8755bf1815f0e7a76603026fa2d99c79abc7b273 (patch) | |
tree | 2dcaac43ccb39c5849db4cc5f37d7120feb5491b /lib/private | |
parent | a4c1a75ee66005f6096461a3cbd2c0c9263ef1ca (diff) | |
download | nextcloud-server-8755bf1815f0e7a76603026fa2d99c79abc7b273.tar.gz nextcloud-server-8755bf1815f0e7a76603026fa2d99c79abc7b273.zip |
fix(storage): Try to delete existing targetdeleteExistingTarget
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
Add same logic to common storage
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/Files/Storage/Common.php | 15 | ||||
-rw-r--r-- | 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)) { |