Skip to content

Commit

Permalink
Merge pull request #20 from denpaforks/master
Browse files Browse the repository at this point in the history
Check that lock file exists, before trying to delete it.
  • Loading branch information
mathroc committed Jul 9, 2017
2 parents 10617e2 + 4fcb011 commit 037ff0b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 9 additions & 0 deletions spec/TH/Lock/FileLockSpec.php
Expand Up @@ -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();
}
}
4 changes: 3 additions & 1 deletion src/FileLock.php
Expand Up @@ -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);
Expand Down

0 comments on commit 037ff0b

Please sign in to comment.