From 5c4e4c55907cad96410ac77547115f03c4adfdd3 Mon Sep 17 00:00:00 2001 From: Git'Fellow <12234510+solracsf@users.noreply.github.com> Date: Tue, 21 May 2024 09:38:47 +0200 Subject: [PATCH 1/2] fix(files): Try to create dir only if it not exists Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com> --- lib/private/Files/Node/Folder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/Files/Node/Folder.php b/lib/private/Files/Node/Folder.php index 148dc28318fa5..091bd3dd0a8db 100644 --- a/lib/private/Files/Node/Folder.php +++ b/lib/private/Files/Node/Folder.php @@ -133,7 +133,7 @@ public function newFolder($path) { $fullPath = $this->getFullPath($path); $nonExisting = new NonExistingFolder($this->root, $this->view, $fullPath); $this->sendHooks(['preWrite', 'preCreate'], [$nonExisting]); - if (!$this->view->mkdir($fullPath)) { + if (!$this->view->is_dir($fullPath) && !$this->view->mkdir($fullPath)) { throw new NotPermittedException('Could not create folder "' . $fullPath . '"'); } $parent = dirname($fullPath) === $this->getPath() ? $this : null; From 77979b147538b7abca83c378bcbd9beaccbf7d9d Mon Sep 17 00:00:00 2001 From: Git'Fellow <12234510+solracsf@users.noreply.github.com> Date: Wed, 22 May 2024 17:26:29 +0200 Subject: [PATCH 2/2] Try create folder first and check if it exists after Co-authored-by: Benjamin Gaussorgues Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com> --- lib/private/Files/Node/Folder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/Files/Node/Folder.php b/lib/private/Files/Node/Folder.php index 091bd3dd0a8db..51b205d545bcb 100644 --- a/lib/private/Files/Node/Folder.php +++ b/lib/private/Files/Node/Folder.php @@ -133,7 +133,7 @@ public function newFolder($path) { $fullPath = $this->getFullPath($path); $nonExisting = new NonExistingFolder($this->root, $this->view, $fullPath); $this->sendHooks(['preWrite', 'preCreate'], [$nonExisting]); - if (!$this->view->is_dir($fullPath) && !$this->view->mkdir($fullPath)) { + if (!$this->view->mkdir($fullPath) && !$this->view->is_dir($fullPath)) { throw new NotPermittedException('Could not create folder "' . $fullPath . '"'); } $parent = dirname($fullPath) === $this->getPath() ? $this : null;