From 85e320bde238a6b12f4dbc419ce7bc4502e4e7c4 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> --- lib/private/Files/Storage/Common.php | 13 +++++++------ lib/private/Files/Storage/Local.php | 10 ++++++---- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/private/Files/Storage/Common.php b/lib/private/Files/Storage/Common.php index fd447d3fa86a6..e363054c909dd 100644 --- a/lib/private/Files/Storage/Common.php +++ b/lib/private/Files/Storage/Common.php @@ -106,13 +106,14 @@ public function __construct($parameters) { * @return bool */ protected function remove($path) { - 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); + } } + return false; } public function is_dir($path) { diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php index 1b908cb2350bf..7dbec7716d8c8 100644 --- a/lib/private/Files/Storage/Local.php +++ b/lib/private/Files/Storage/Local.php @@ -380,10 +380,12 @@ public function rename($source, $target): bool { 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)) {