Переглянути джерело

Merge pull request #49315 from nextcloud/deleteExistingTarget

Kate 1 день тому
батько
коміт
bdb3d63212

+ 9 - 6
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 {

+ 6 - 4
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)) {