File tree Expand file tree Collapse file tree 3 files changed +25
-2
lines changed Expand file tree Collapse file tree 3 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,12 @@ public function meta($key = null)
6565 return $ meta ;
6666 }
6767
68+ // this handles asset::make() without save()
69+ // e.g. when checking a file exists already when uploading
70+ if (! $ this ->disk ()->exists ($ this ->path ())) {
71+ return ['data ' => []];
72+ }
73+
6874 return Blink::once ($ this ->metaCacheKey (), function () {
6975 if ($ model = app ('statamic.eloquent.assets.model ' )::where ([
7076 'container ' => $ this ->containerHandle (),
@@ -101,7 +107,7 @@ public function metaExists()
101107 'container ' => $ this ->containerHandle (),
102108 'folder ' => $ this ->folder (),
103109 'basename ' => $ this ->basename (),
104- ])->count () > 0 ;
110+ ])->exists () ;
105111 });
106112 }
107113
Original file line number Diff line number Diff line change @@ -136,7 +136,7 @@ public function add($path)
136136 $ this ->add ($ dir );
137137 }
138138
139- $ this ->folders ->push (['path ' => $ path ]);
139+ $ this ->folders ->push (['path ' => $ path, ' type ' => ' dir ' ]);
140140
141141 return $ this ;
142142 }
Original file line number Diff line number Diff line change @@ -54,4 +54,21 @@ public function saving_an_asset_clears_the_eloquent_blink_cache()
5454
5555 $ this ->assertFalse (Facades \Blink::has ("eloquent-asset- {$ asset ->id ()}" ));
5656 }
57+
58+ #[Test]
59+ public function making_an_asset_without_saving_doesnt_make_a_meta_exists_blink_cache_entry ()
60+ {
61+ Facades \Blink::flush ();
62+
63+ $ this ->assertCount (0 , Facades \Blink::allStartingWith ('eloquent-asset-meta-exists- ' ));
64+
65+ Storage::disk ('test ' )->put ('test.jpg ' , '' );
66+ $ asset = Facades \Asset::make ()->container ('test ' )->path ('test.jpg ' );
67+
68+ $ this ->assertCount (0 , Facades \Blink::allStartingWith ('eloquent-asset-meta-exists- ' ));
69+
70+ $ asset ->save ();
71+
72+ $ this ->assertCount (1 , Facades \Blink::allStartingWith ('eloquent-asset-meta-exists- ' ));
73+ }
5774}
You can’t perform that action at this time.
0 commit comments