File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66
77- Requires PHP ` 8.4 `
88- ` Innmind\OperatingSystem\Remote::sql() ` now returns an ` Innmind\Immutable\Attempt `
9+ - ` Innmind\OperatingSystem\Filesystem::mount() ` now longer automatically create the directory
910
1011## 6.2.0 - 2025-08-10
1112
Original file line number Diff line number Diff line change 1010use Innmind \Filesystem \{
1111 Adapter as Filesystem ,
1212 CaseSensitivity ,
13+ Exception \RecoverMount ,
1314};
1415use Innmind \FileWatch \Watch ;
1516use Innmind \Server \Status \EnvironmentPath ;
@@ -595,9 +596,21 @@ public function clock(): Clock
595596 #[\NoDiscard]
596597 public function filesystem (Path $ path ): Attempt
597598 {
598- return ($ this ->filesystem )($ path , $ this )->map (
599- fn ($ adapter ) => ($ this ->mapFilesystem )($ adapter , $ this ),
599+ $ map = fn (Filesystem $ adapter ): Filesystem => ($ this ->mapFilesystem )(
600+ $ adapter ,
601+ $ this ,
600602 );
603+
604+ return ($ this ->filesystem )($ path , $ this )
605+ ->mapError (static fn ($ e ) => match (true ) {
606+ $ e instanceof RecoverMount => new RecoverMount (
607+ static fn () => $ e
608+ ->recover ()
609+ ->map ($ map ),
610+ ),
611+ default => $ e ,
612+ })
613+ ->map ($ map );
601614 }
602615
603616 /**
Original file line number Diff line number Diff line change 66use Innmind \Filesystem \{
77 Adapter ,
88 File \Content ,
9+ Directory ,
10+ Name ,
911};
1012use Innmind \Url \Path ;
1113use Innmind \Server \Control \Server \Processes ;
@@ -76,16 +78,28 @@ public function mount(Path $path): Attempt
7678 #[\NoDiscard]
7779 public function contains (Path $ path ): bool
7880 {
79- // todo find a way to not directly access the filesystem
80- if (!\file_exists ($ path ->toString ())) {
81- return false ;
82- }
81+ $ dir = \rtrim (\dirname ($ path ->toString ()), '/ ' ).'/ ' ;
82+ $ name = \basename ($ path ->toString ());
8383
84- if ($ path ->directory () && !\is_dir ($ path ->toString ())) {
85- return false ;
84+ $ exists = $ this
85+ ->config
86+ ->filesystem (Path::of ($ dir ))
87+ ->maybe ();
88+
89+ // empty when the path === '/'
90+ if ($ name !== '' ) {
91+ $ exists = $ exists
92+ ->flatMap (static fn ($ adapter ) => $ adapter ->get (Name::of ($ name )))
93+ ->filter (static fn ($ file ) => match (true ) {
94+ $ path ->directory () && !($ file instanceof Directory) => false ,
95+ default => true ,
96+ });
8697 }
8798
88- return true ;
99+ return $ exists ->match (
100+ static fn () => true ,
101+ static fn () => false ,
102+ );
89103 }
90104
91105 /**
Original file line number Diff line number Diff line change 1515 File \Content ,
1616 Directory ,
1717 CaseSensitivity ,
18+ Recover ,
1819};
1920use Innmind \Url \Path ;
2021use Symfony \Component \Filesystem \Filesystem as FS ;
@@ -62,6 +63,7 @@ public function testPersistingFileOnCaseInsensitiveFilesystem()
6263 $ adapter = $ os
6364 ->filesystem ()
6465 ->mount (Path::of ($ path ))
66+ ->recover (Recover::mount (...))
6567 ->unwrap ();
6668 $ adapter ->add (
6769 $ directory = Directory::named ('0 ' )
Original file line number Diff line number Diff line change @@ -79,6 +79,9 @@ public function testContainsDirectory()
7979 \mkdir ('/tmp/some-dir/ ' );
8080 $ this ->assertTrue ($ filesystem ->contains (Path::of ('/tmp/some-dir/ ' )));
8181 \rmdir ('/tmp/some-dir/ ' );
82+ \file_put_contents ('/tmp/foo ' , 'data ' );
83+ $ this ->assertFalse ($ filesystem ->contains (Path::of ('/tmp/foo/ ' )));
84+ \unlink ('/tmp/foo ' );
8285 }
8386
8487 public function testWatch ()
You can’t perform that action at this time.
0 commit comments