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 10
10
namespace Nette \Bridges \CacheDI ;
11
11
12
12
use Nette ;
13
+ use Nette \Utils \FileSystem ;
13
14
14
15
15
16
/**
16
17
* Cache extension for Nette DI.
17
18
*/
18
19
final class CacheExtension extends Nette \DI \CompilerExtension
19
20
{
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
+ ) {
26
24
}
27
25
28
26
29
27
public function loadConfiguration (): void
30
28
{
29
+ if (!FileSystem::isAbsolute ($ this ->tempDir )) {
30
+ throw new Nette \InvalidArgumentException ("Cache directory must be absolute, ' $ this ->tempDir ' given. " );
31
+ }
31
32
$ dir = $ this ->tempDir . '/cache ' ;
32
- Nette \ Utils \ FileSystem::createDir ($ dir );
33
+ FileSystem::createDir ($ dir );
33
34
if (!is_writable ($ dir )) {
34
35
throw new Nette \InvalidStateException ("Make directory ' $ dir' writable. " );
35
36
}
Original file line number Diff line number Diff line change @@ -55,8 +55,8 @@ class FileStorage implements Nette\Caching\Storage
55
55
56
56
public function __construct (string $ dir , ?Journal $ journal = null )
57
57
{
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 . " );
60
60
}
61
61
62
62
$ this ->dir = $ dir ;
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ require __DIR__ . '/../bootstrap.php';
17
17
Assert::exception (
18
18
fn () => new FileStorage (getTempDir () . '/missing ' ),
19
19
Nette \DirectoryNotFoundException::class,
20
- "Directory '%a%' not found. " ,
20
+ "Directory '%a%' not found or is not absolute . " ,
21
21
);
22
22
23
23
You can’t perform that action at this time.
0 commit comments