Skip to content

Commit d7798d5

Browse files
authored
Merge pull request #49411 from nextcloud/backport/49315/stable28
[stable28] fix(storage): Try to delete existing target
2 parents 03300ae + 85e320b commit d7798d5

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

lib/private/Files/Storage/Common.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,14 @@ public function __construct($parameters) {
106106
* @return bool
107107
*/
108108
protected function remove($path) {
109-
if ($this->is_dir($path)) {
110-
return $this->rmdir($path);
111-
} elseif ($this->is_file($path)) {
112-
return $this->unlink($path);
113-
} else {
114-
return false;
109+
if ($this->file_exists($path)) {
110+
if ($this->is_dir($path)) {
111+
return $this->rmdir($path);
112+
} elseif ($this->is_file($path)) {
113+
return $this->unlink($path);
114+
}
115115
}
116+
return false;
116117
}
117118

118119
public function is_dir($path) {

lib/private/Files/Storage/Local.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,10 +380,12 @@ public function rename($source, $target): bool {
380380
return false;
381381
}
382382

383-
if ($this->is_dir($target)) {
384-
$this->rmdir($target);
385-
} elseif ($this->is_file($target)) {
386-
$this->unlink($target);
383+
if ($this->file_exists($target)) {
384+
if ($this->is_dir($target)) {
385+
$this->rmdir($target);
386+
} elseif ($this->is_file($target)) {
387+
$this->unlink($target);
388+
}
387389
}
388390

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

0 commit comments

Comments
 (0)