From f439e71ad07ab2063632cd8f6eef8be84297d4a5 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Wed, 6 Aug 2014 19:23:21 +0300 Subject: [PATCH] Fix warnings when locking the file if directory doesn't exist --- system/src/Grav/Common/Filesystem/File/General.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/system/src/Grav/Common/Filesystem/File/General.php b/system/src/Grav/Common/Filesystem/File/General.php index d9530f499..91fbb66c7 100644 --- a/system/src/Grav/Common/Filesystem/File/General.php +++ b/system/src/Grav/Common/Filesystem/File/General.php @@ -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()) {