Repository navigation
[6.x] Don't make the directory before every write to a Flysystem disk - #15855
Open
DanielDarrenJones wants to merge 1 commit into
Open
DanielDarrenJones wants to merge 1 commit into
DanielDarrenJones wants to merge 1 commit into
Conversation
DanielDarrenJones
marked this pull request as ready for review
November 12, 2026 00:07
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AbstractAdapter::put()callsmakeDirectory()before it writes. Flysystem creates any missing parent directories as part of a write, so forFlysystemAdapterthe call is redundant.On a local disk it costs nothing worth mentioning. On a remote disk it is one more request for every file written, and on S3 it leaves an empty
folder/object behind each time, since a directory there is just another object.FlysystemAdapternow has its ownput()that writes directly. The localFilesystemAdapter, which wraps Laravel'sFilesystemand does need the directory made first, is unchanged.Other adapters
Flysystem 3's FTP adapter writes through
writeStream(), which callsensureParentDirectoryExists(), and the SFTP (phpseclib v3) adapter'supload()does the same. I checked that by reading their source rather than by running them. Third-party adapters weren't checked.Benchmark
An asset container of 20,000 images on a Flysystem adapter wrapped round the local one that counts every call, so Statamic takes the paths it takes on S3 (no real S3 was used; the counts are exact). Against
6.xat 7097691..metafile yetTests
FlysystemAdapterTest::putting_a_file_does_not_make_the_directory_firstfails without the change. The existingputs_content_into_a_file_in_a_subdirectorystill passes.