Skip asset copy when destination already has the file#1336
Open
lacatoire wants to merge 1 commit intophpDocumentor:mainfrom
Open
Skip asset copy when destination already has the file#1336lacatoire wants to merge 1 commit intophpDocumentor:mainfrom
lacatoire wants to merge 1 commit intophpDocumentor:mainfrom
Conversation
When an RST project references the same image from multiple documents, AssetsExtension::copyAsset hits the Flysystem Local adapter on every invocation. On second and subsequent copies the adapter re-enters ensureDirectory() and, on Flysystem v1, logs a noisy 'Impossible to create the root directory ... mkdir(): File exist' error even though the HTML output itself is fine. Short-circuit the copy when the destination filesystem already reports the target path: one stat per asset reference, no redundant write, no noisy mkdir attempt on repeated renders. A new AssetsExtension unit test covers the skip path, the first-copy path, and idempotency across two consecutive asset() calls. refs phpDocumentor/phpDocumentor#3635
324ccc0 to
fdda718
Compare
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.
When an RST project references the same image from multiple documents,
AssetsExtension::copyAssetcalls$destination->put()once per reference. On repeat copies the Flysystem Local adapter re-entersensureDirectory()and, on Flysystem v1, logs a noisyImpossible to create the root directory ... mkdir(): File existerror even though the HTML output itself is fine (see phpDocumentor/phpDocumentor#3635; v3 self-guards viais_dir()beforemkdir).Short-circuit the copy when the destination already reports the target path: one extra stat per asset reference, no redundant
put, no noisy mkdir attempt on repeat renders. The scope of this change is explicit: it silences the error for the repeat render case that matches the reporter's symptom. A collision where a non-directory already lives at the parent path (someone else put a bare file there) is out of scope, and the error in that case remains meaningful.A new
AssetsExtensionTestcovers the skip path, the first-copy path, and idempotency across two consecutiveasset()calls, and asserts no error is logged on those happy paths.refs phpDocumentor/phpDocumentor#3635