Skip to content

Commit

Permalink
Ignore deletion exception
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski committed Dec 8, 2024
1 parent 0dc7baf commit 1696222
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/FileMutex.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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();
}
}

0 comments on commit 1696222

Please sign in to comment.