diff --git a/lib/private/Files/Storage/Common.php b/lib/private/Files/Storage/Common.php index d4f3d1ddc847d..49fdde5636b01 100644 --- a/lib/private/Files/Storage/Common.php +++ b/lib/private/Files/Storage/Common.php @@ -68,13 +68,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 869b309b2b453..c51be70d31dc8 100644 --- a/lib/private/Files/Storage/Local.php +++ b/lib/private/Files/Storage/Local.php @@ -345,10 +345,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)) {