Skip to content

Commit 18aec8c

Browse files
committed
ensure cache directory
1 parent 2881df9 commit 18aec8c

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

src/Brainbits/Blocking/Adapter/FilesystemAdapter.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,24 @@ public function get(IdentifierInterface $identifier)
111111
*/
112112
protected function getFilename(IdentifierInterface $identifier)
113113
{
114-
return $this->root . '/' . $identifier;
114+
return $this->ensureDirectoryExists($this->root) . '/' . $identifier;
115+
}
116+
117+
/**
118+
* Ensure directory exists
119+
*
120+
* @param string $filename
121+
* @return string
122+
* @throws \Exception
123+
*/
124+
protected function ensureDirectoryExists($dirname)
125+
{
126+
if (!file_exists($dirname)) {
127+
if (!mkdir($dirname, 0777, true)) {
128+
throw new \Exception('Can\'t create block dir ' . $dirname);
129+
}
130+
}
131+
132+
return $dirname;
115133
}
116134
}

0 commit comments

Comments
 (0)