From 8927f457a5774695e3b9a0b4119ab7a756d842b2 Mon Sep 17 00:00:00 2001 From: Aaron Piotrowski Date: Sun, 8 Dec 2024 11:37:29 -0600 Subject: [PATCH] Try "a" mode --- src/FileMutex.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/FileMutex.php b/src/FileMutex.php index 0881bdf..d4b4392 100644 --- a/src/FileMutex.php +++ b/src/FileMutex.php @@ -7,6 +7,7 @@ use Amp\Sync\Mutex; use Amp\Sync\SyncException; use function Amp\delay; +use const Amp\Process\IS_WINDOWS; final class FileMutex implements Mutex { @@ -39,7 +40,7 @@ public function acquire(?Cancellation $cancellation = null): Lock // so set an asynchronous timer and try again. for ($attempt = 0; true; ++$attempt) { try { - $file = $this->filesystem->openFile($this->fileName, 'c'); + $file = $this->filesystem->openFile($this->fileName, 'a'); if ($file->lock(LockMode::Exclusive)) { return new Lock(fn () => $this->release($file)); }