Skip to content

Commit b9d9a53

Browse files
committed
FileStorage: lock uses mode c+
1 parent 8c7ca63 commit b9d9a53

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/Caching/Storages/FileStorage.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,16 +147,11 @@ public function lock($key)
147147
if ($this->useDirs && !is_dir($dir = dirname($cacheFile))) {
148148
@mkdir($dir); // @ - directory may already exist
149149
}
150-
$handle = @fopen($cacheFile, 'r+b'); // @ - file may not exist
151-
if (!$handle) {
152-
$handle = fopen($cacheFile, 'wb');
153-
if (!$handle) {
154-
return;
155-
}
150+
$handle = fopen($cacheFile, 'c+b');
151+
if ($handle) {
152+
$this->locks[$key] = $handle;
153+
flock($handle, LOCK_EX);
156154
}
157-
158-
$this->locks[$key] = $handle;
159-
flock($handle, LOCK_EX);
160155
}
161156

162157

0 commit comments

Comments
 (0)