From 1696222b56eb0b82eb91bb10f8e9154dcb655d79 Mon Sep 17 00:00:00 2001 From: Aaron Piotrowski Date: Sun, 8 Dec 2024 11:32:10 -0600 Subject: [PATCH] Ignore deletion exception --- src/FileMutex.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/FileMutex.php b/src/FileMutex.php index 0881bdf..fa589ea 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 { @@ -61,13 +62,11 @@ public function acquire(?Cancellation $cancellation = null): Lock private function release(File $file): void { try { - $this->filesystem->deleteFile($this->fileName); // Delete file while holding the lock. - $file->close(); - } catch (FilesystemException $exception) { - throw new SyncException( - 'Failed to unlock the mutex file: ' . $this->fileName, - previous: $exception, - ); + $this->filesystem->deleteFile($this->fileName); + } catch (FilesystemException) { + // Ignore failure to delete the file. } + + $file->close(); } }