]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(storage): Try to delete existing target backport/49315/stable29 49409/head
authorGit'Fellow <12234510+solracsf@users.noreply.github.com>
Fri, 15 Nov 2024 18:50:16 +0000 (19:50 +0100)
committerGit'Fellow <12234510+solracsf@users.noreply.github.com>
Thu, 21 Nov 2024 06:41:54 +0000 (07:41 +0100)
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
lib/private/Files/Storage/Common.php
lib/private/Files/Storage/Local.php

index d2a344a8217aa5511522486e4e9d138f94d28792..cff19e33dcef072b00f2207c4851d702254c151b 100644 (file)
@@ -108,13 +108,14 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage {
         * @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) {
index ca2113add75d0aa2fc22c6363b1d400a5c35d8e8..8fec24996891f134885cc99e74cafb41fe99e5d1 100644 (file)
@@ -380,10 +380,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)) {