Skip to content

Commit bdb3d63

Browse files
Merge pull request #49315 from nextcloud/deleteExistingTarget
2 parents 3822db5 + 8755bf1 commit bdb3d63

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

lib/private/Files/Storage/Common.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,16 @@ public function __construct(array $parameters) {
6969
}
7070

7171
protected function remove(string $path): bool {
72-
if ($this->is_dir($path)) {
73-
return $this->rmdir($path);
74-
} elseif ($this->is_file($path)) {
75-
return $this->unlink($path);
76-
} else {
77-
return false;
72+
if ($this->file_exists($path)) {
73+
if ($this->is_dir($path)) {
74+
return $this->rmdir($path);
75+
} elseif ($this->is_file($path)) {
76+
return $this->unlink($path);
77+
} else {
78+
return false;
79+
}
7880
}
81+
return false;
7982
}
8083

8184
public function is_dir(string $path): bool {

lib/private/Files/Storage/Local.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,12 @@ public function rename(string $source, string $target): bool {
342342
return false;
343343
}
344344

345-
if ($this->is_dir($target)) {
346-
$this->rmdir($target);
347-
} elseif ($this->is_file($target)) {
348-
$this->unlink($target);
345+
if ($this->file_exists($target)) {
346+
if ($this->is_dir($target)) {
347+
$this->rmdir($target);
348+
} elseif ($this->is_file($target)) {
349+
$this->unlink($target);
350+
}
349351
}
350352

351353
if ($this->is_dir($source)) {

0 commit comments

Comments
 (0)