Skip to content

[6.x] Keep the asset listing cached on remote disks when the watcher is enabled - #15980

Merged
jasonvarga merged 1 commit into
statamic:6.xfrom
edalzell:asset-listing-ttl-remote-disks
Nov 23, 2026
Merged

jasonvarga merged 1 commit into
statamic:6.xfrom
edalzell:asset-listing-ttl-remote-disks

Conversation

@edalzell

Copy link
Copy Markdown
Contributor

Part of #15970 (the ttl() item in Group A). Related to #14061.

With the Stache watcher enabled, AssetContainerContents::ttl() returns 0, 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 one LIST call per 1,000 objects each time, e.g. once per InsertMultipleJob chunk.

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.

@edalzell
edalzell marked this pull request as ready for review November 20, 2026 00:41

private function isLocal(): bool
{
return $this->container->disk()->filesystem()->getAdapter() instanceof LocalFilesystemAdapter;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jasonvarga
jasonvarga enabled auto-merge (squash) November 23, 2026 16:19
@jasonvarga
jasonvarga merged commit 7ce7a00 into statamic:6.x Nov 23, 2026
62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants