Skip to content

Commit 037ff0b

Browse files
authoredJul 9, 2017
Merge pull request #20 from denpaforks/master
Check that lock file exists, before trying to delete it.
2 parents 10617e2 + 4fcb011 commit 037ff0b

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed
 

‎spec/TH/Lock/FileLockSpec.php

+9
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,13 @@ public function it_can_acquire_then_release_and_acquire_again()
124124

125125
$this->release();
126126
}
127+
128+
public function it_does_not_throw_when_lock_file_does_not_exists()
129+
{
130+
$this->acquire();
131+
132+
unlink($this->lock_file);
133+
134+
$this->release();
135+
}
127136
}

‎src/FileLock.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ public function release()
9797
}
9898

9999
if ($this->remove_on_release && $this->flock(LOCK_EX | LOCK_NB)) {
100-
unlink($this->lock_file);
100+
if (is_file($this->lock_file)) {
101+
unlink($this->lock_file);
102+
}
101103
}
102104

103105
$this->flock(LOCK_UN);

0 commit comments

Comments
 (0)
Please sign in to comment.