Keep locally installed files when pulling onto an existing site#4283
Open
epeicher wants to merge 2 commits into
Open
Keep locally installed files when pulling onto an existing site#4283epeicher wants to merge 2 commits into
epeicher wants to merge 2 commits into
Conversation
…1951) The first pull passes --force to flat-docroot to overwrite the blank install, which also deleted every plugin, theme and upload already in wp-content. Pass reprint's --preserve-local-content so wp-content is merged rather than replaced. It goes on every pull, not just the first: once merged, wp-content is a real directory, and a later pull without the flag fails trying to symlink over it. Re-run flat-docroot after the deferred file tail as well. Those files land in the raw directory after the flatten, and the flattened site now links entries individually rather than aliasing the whole wp-content, so without a second pass they would stay unlinked until the next pull.
Collaborator
📊 Performance Test ResultsComparing 978b5c9 vs trunk app-size
site-editor
site-startup
Results are median values from multiple test runs. Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff) |
The exact-equality assertion predates the flag. Also assert the delta pull still passes it: without --force it is what lets the flatten succeed over the real wp-content directory the first merge left behind.
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.
Related issues
How AI was used in this PR
Claude Code was used to investigate the root cause, implement the change here and in reprint#383, and run the end-to-end verification below. The diff was reviewed by hand; an earlier revision of the reprint docblocks referenced Studio commands and was rewritten, since reprint is a library and shouldn't document its consumers.
Proposed Changes
Pulling onto a site that already has content deleted everything the user had installed. Create a site, install a plugin, pull → the plugin is gone. Themes, uploads and any custom
wp-contentfolder went with it.The first pull passes
--forcetoflat-docrootso it can overwrite the blank install. But for the common layout,flat-docrootwantswp-contentto be a single symlink into the raw scratch dir, and--forcemakes it recursively delete the existing realwp-contentbefore creating that link. Incremental pulls were unaffected, because--forceisn't passed andwp-contentis already a symlink — which is why this only ever showed up on the first pull.This passes reprint's new
--preserve-local-content, sowp-contentis merged instead of replaced: entries the remote also has are linked (the remote wins), and entries that exist only locally are left alone.Two things worth flagging for review:
wp-contentis a real directory, and a later pull without the flag fails trying to symlink over it.flat-docrootis re-run after the deferred file tail. Those files land in the raw dir after the flatten, and the site now links entries individually rather than aliasing the wholewp-content, so without a second pass late-arriving media would stay unlinked until the next pull.Behaviour change:
wp-contentis now a real directory rather than a single symlink, so plugins installed after a pull live in the site directory instead of reprint's raw scratch. That's the cleaner ownership split and is what makes them survive, but it is a change in where files land.Note this is a different problem from
preserveUnselectedLocalContent, which protects content the user chose not to pull; this protects content the remote never had.Testing Instructions
Requires a build with reprint#383 in the bundled phar.
studio create --name test --path ~/Studio/test --startwp-content/plugins/). Optionally add a theme, an upload and a customwp-contentfolder.studio pull-reprint --path ~/Studio/test --url <a connected site>ls -ld ~/Studio/test/wp-contentshows a real directory.Verified end-to-end on a real connected site: first pull and incremental pull both exit 0, all local-only content preserved, remote content linked, no dangling symlinks, site returns 200.
npm -w wp-studio run buildis clean.Pre-merge Checklist