diff --git a/src/FileMutex.php b/src/FileMutex.php index f0f2338..cf66cef 100644 --- a/src/FileMutex.php +++ b/src/FileMutex.php @@ -69,10 +69,15 @@ public function acquire(?Cancellation $cancellation = null): Lock */ private function release(File $file): void { + $file->close(); + try { - $this->filesystem->deleteFile($this->fileName); // Delete file while holding the lock. - $file->close(); + $this->filesystem->deleteFile($this->fileName); } catch (FilesystemException $exception) { + if (IS_WINDOWS) { + return; // Windows will fail to delete the file if another handle is open. + } + throw new SyncException( 'Failed to unlock the mutex file: ' . $this->fileName, previous: $exception,