diff --git a/spec/TH/Lock/FileLockSpec.php b/spec/TH/Lock/FileLockSpec.php index de64881..60e6c51 100644 --- a/spec/TH/Lock/FileLockSpec.php +++ b/spec/TH/Lock/FileLockSpec.php @@ -124,4 +124,13 @@ public function it_can_acquire_then_release_and_acquire_again() $this->release(); } + + public function it_does_not_throw_when_lock_file_does_not_exists() + { + $this->acquire(); + + unlink($this->lock_file); + + $this->release(); + } } diff --git a/src/FileLock.php b/src/FileLock.php index f9a3549..ac17183 100644 --- a/src/FileLock.php +++ b/src/FileLock.php @@ -97,7 +97,9 @@ public function release() } if ($this->remove_on_release && $this->flock(LOCK_EX | LOCK_NB)) { - unlink($this->lock_file); + if (is_file($this->lock_file)) { + unlink($this->lock_file); + } } $this->flock(LOCK_UN);