From 10842e96ec5c011faa41dcbb9a12ea2bf2da7414 Mon Sep 17 00:00:00 2001 From: Olavo Belloc Date: Mon, 4 Aug 2025 11:58:18 +0200 Subject: [PATCH] Fix race-condition with multiple workers When running ssg with multiple workers, different forked processes might check for an existing folder and attempt to create it "simultaneously", which will cause makeDirectory to fail (folder already exists) and ssg to abort. The fix uses 'force' to ignore errors on makeDirectory(). If it fails with errors other than 'folder already exists', then the following put() should also fail, meaning, it won't go unnoticed. --- src/Page.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Page.php b/src/Page.php index 1145d1f..b0b4b8d 100644 --- a/src/Page.php +++ b/src/Page.php @@ -63,9 +63,7 @@ protected function write($request) $html = $response->getContent(); - if (! $this->files->exists($this->directory())) { - $this->files->makeDirectory($this->directory(), 0755, true); - } + $this->files->makeDirectory($this->directory(), 0755, true, true); $this->files->put($this->path(), $html);