mirror of
https://github.com/getgrav/grav.git
synced 2025-10-26 07:56:07 +01:00
Fix warnings when locking the file if directory doesn't exist
This commit is contained in:
committed by
Djamil Legato
parent
b5982ea965
commit
f439e71ad0
@@ -143,6 +143,9 @@ class General implements FileInterface
|
||||
public function lock($block = true)
|
||||
{
|
||||
if (!$this->handle) {
|
||||
if (!$this->mkdir(dirname($this->filename))) {
|
||||
throw new \RuntimeException('Creating directory failed for ' . $this->filename);
|
||||
}
|
||||
$this->handle = fopen($this->filename, 'wb+');
|
||||
}
|
||||
$lock = $block ? LOCK_EX : LOCK_EX | LOCK_NB;
|
||||
@@ -253,9 +256,6 @@ class General implements FileInterface
|
||||
$this->content($data);
|
||||
}
|
||||
|
||||
if (!$this->mkdir(dirname($this->filename))) {
|
||||
throw new \RuntimeException('Creating directory failed for ' . $this->filename);
|
||||
}
|
||||
if (!$this->locked) {
|
||||
// Obtain blocking lock or fail.
|
||||
if (!$this->lock()) {
|
||||
|
||||
Reference in New Issue
Block a user