Repository navigation
[6.x] Keep the asset listing cached on remote disks when the watcher is enabled - #15980
Conversation
|
|
||
| private function isLocal(): bool | ||
| { | ||
| return $this->container->disk()->filesystem()->getAdapter() instanceof LocalFilesystemAdapter; |
There was a problem hiding this comment.
This misses local disks that Laravel wraps. A disk with 'read-only' => true gets wrapped in ReadOnlyFilesystemAdapter, and a disk with a prefix (including any scoped disk) gets wrapped in PathPrefixedAdapter (see FilesystemManager::createFlysystem()). Neither is a LocalFilesystemAdapter, so those local disks would be treated as remote and lose the watcher behavior.
Could you check the disk's config instead? Look up filesystems.disks.{handle}, follow a scoped driver to its parent disk, and check for driver === 'local'. A test case for a scoped or read-only local disk would be good too.
There was a problem hiding this comment.
I tested this and getAdapter() still returns the LocalFilesystemAdapter for read-only, prefixed and scoped local disks. createFlysystem() only wraps the adapter inside the Flysystem instance; the disk itself is given the original. With the watcher on, none of the three cache the listing.
Happy to add a scoped disk test, but it would need league/flysystem-path-prefixing as a dev dependency.
Part of #15970 (the
ttl()item in Group A). Related to #14061.With the Stache watcher enabled,
AssetContainerContents::ttl()returns0, so the container listing is never kept in the cache and every request or queued job does a full recursive listing. On S3 that's oneLISTcall per 1,000 objects each time, e.g. once perInsertMultipleJobchunk.Now the listing is only left uncached when the watcher is on and the container's disk is local, where listing is cheap and files change on disk during development. Remote disks stay cached as they are with the watcher off, so files added to the bucket outside Statamic need the asset cache cleared to show up, same as in production.