I'm encountering caching issues with the ->exists() method in the Asset.php file. I have some code that imports media files from our old CMS, but it seems to be missing metadata.
I noticed that the generateMeta() method, which is called during the save process, doesn't properly handle the metadata section. The issue seems to be that the file list used for comparison is cached and doesn't get updated or cleared, even when media files are saved or deleted.
The method includes the following code:
$files = Blink::once($this->container()->handle().'::files', function () {
return $this->container()->files();
});
The data returned from $this->container()->files() / $this->container()->contents() is already cached and gets updated during the save/delete process for assets.
I believe the caching in the Asset.php file is redundant and should be removed.
As a temporary workaround, I can call Blink::forget($container->handle().'::files'); before $asset->save(), and metadata is successfully added as expected.
I'm encountering caching issues with the ->exists() method in the Asset.php file. I have some code that imports media files from our old CMS, but it seems to be missing metadata.
I noticed that the generateMeta() method, which is called during the save process, doesn't properly handle the metadata section. The issue seems to be that the file list used for comparison is cached and doesn't get updated or cleared, even when media files are saved or deleted.
The method includes the following code:
The data returned from
$this->container()->files()
/$this->container()->contents()
is already cached and gets updated during the save/delete process for assets.I believe the caching in the Asset.php file is redundant and should be removed.
As a temporary workaround, I can call
Blink::forget($container->handle().'::files');
before$asset->save()
, and metadata is successfully added as expected.