Преглед изворни кода

Merge pull request #49315 from nextcloud/deleteExistingTarget

Kate пре 4 дана
родитељ
комит
bdb3d63212
2 измењених фајлова са 15 додато и 10 уклоњено
  1. 9 6
      lib/private/Files/Storage/Common.php
  2. 6 4
      lib/private/Files/Storage/Local.php

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