Skip to content

Commit

Permalink
fix(storage): Try to delete existing target
Browse files Browse the repository at this point in the history
Signed-off-by: Git'Fellow <[email protected]>

Add same logic to common storage
  • Loading branch information
solracsf committed Nov 20, 2024
1 parent a4c1a75 commit 8755bf1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
15 changes: 9 additions & 6 deletions lib/private/Files/Storage/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,16 @@ public function __construct(array $parameters) {
}

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 {
Expand Down
10 changes: 6 additions & 4 deletions lib/private/Files/Storage/Local.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,12 @@ public function rename(string $source, string $target): bool {
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)) {
Expand Down

0 comments on commit 8755bf1

Please sign in to comment.