]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(storage): Try to delete existing target deleteExistingTarget 49315/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>
Wed, 20 Nov 2024 08:42:33 +0000 (09:42 +0100)
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
Add same logic to common storage

lib/private/Files/Storage/Common.php
lib/private/Files/Storage/Local.php

index 334ca34294ec53b6fffef101b989a73d54b0fb89..8a95e6373723702ac88c9b63463d9aa819f291b3 100644 (file)
@@ -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 {
index 6f645c74c11e8f450d83564548c1240675f28327..f06e409cd8fe344f34ac8dfee8cbaf3dabdf321a 100644 (file)
@@ -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)) {