File tree Expand file tree Collapse file tree 3 files changed +11
-10
lines changed Expand file tree Collapse file tree 3 files changed +11
-10
lines changed Original file line number Diff line number Diff line change 1010namespace Nette \Bridges \CacheDI ;
1111
1212use Nette ;
13+ use Nette \Utils \FileSystem ;
1314
1415
1516/**
1617 * Cache extension for Nette DI.
1718 */
1819final class CacheExtension extends Nette \DI \CompilerExtension
1920{
20- private string $ tempDir ;
21-
22-
23- public function __construct (string $ tempDir )
24- {
25- $ this ->tempDir = $ tempDir ;
21+ public function __construct (
22+ private string $ tempDir ,
23+ ) {
2624 }
2725
2826
2927 public function loadConfiguration (): void
3028 {
29+ if (!FileSystem::isAbsolute ($ this ->tempDir )) {
30+ throw new Nette \InvalidArgumentException ("Cache directory must be absolute, ' $ this ->tempDir ' given. " );
31+ }
3132 $ dir = $ this ->tempDir . '/cache ' ;
32- Nette \ Utils \ FileSystem::createDir ($ dir );
33+ FileSystem::createDir ($ dir );
3334 if (!is_writable ($ dir )) {
3435 throw new Nette \InvalidStateException ("Make directory ' $ dir' writable. " );
3536 }
Original file line number Diff line number Diff line change @@ -55,8 +55,8 @@ class FileStorage implements Nette\Caching\Storage
5555
5656 public function __construct (string $ dir , ?Journal $ journal = null )
5757 {
58- if (!is_dir ($ dir )) {
59- throw new Nette \DirectoryNotFoundException ("Directory ' $ dir' not found. " );
58+ if (!is_dir ($ dir ) || ! Nette \ Utils \FileSystem:: isAbsolute ( $ dir ) ) {
59+ throw new Nette \DirectoryNotFoundException ("Directory ' $ dir' not found or is not absolute . " );
6060 }
6161
6262 $ this ->dir = $ dir ;
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ require __DIR__ . '/../bootstrap.php';
1717Assert::exception (
1818 fn () => new FileStorage (getTempDir () . '/missing ' ),
1919 Nette \DirectoryNotFoundException::class,
20- "Directory '%a%' not found. " ,
20+ "Directory '%a%' not found or is not absolute . " ,
2121);
2222
2323
You can’t perform that action at this time.
0 commit comments