fix(migration): skip backup when config content is unchanged (fixes #3222)#3301
Open
MoerAI wants to merge 2 commits intocode-yeongyu:devfrom
Open
fix(migration): skip backup when config content is unchanged (fixes #3222)#3301MoerAI wants to merge 2 commits intocode-yeongyu:devfrom
MoerAI wants to merge 2 commits intocode-yeongyu:devfrom
Conversation
Contributor
Author
|
I have read the CLA Document and I hereby sign the CLA |
There was a problem hiding this comment.
No issues found across 1 file
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Auto-approved: Prevents redundant file writes and backups by checking for content changes. Safely updates in-memory config state and returns false correctly when no disk I/O occurs.
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.
Summary
.bak.<timestamp>backup files on every startup when no config changes are neededProblem
migrateConfigFile()setsneedsWrite=truein several code paths that update migration tracking state (sidecar writes, stripping legacy_migrationsfield) without actually changing the config file body. WhenneedsWriteis true, a backup file is unconditionally created and the config is rewritten, even when the output is identical to the existing file. This causes a new.bak.<timestamp>file to accumulate on every OpenCode startup.Fix
Added a content comparison before the backup/write block. The function now reads the existing config file content and compares it against the serialized migration output. If they are identical, the function applies in-memory mutations (e.g. stripped
_migrations) and returnsfalsewithout touching the filesystem. Backup and rewrite only occur when the config content has actually changed.Changes
src/shared/migration/config-migration.tsFixes #3222
Summary by cubic
Skip creating
.bak.<timestamp>files and rewrites during config migration when the migrated output matches the original in-memory config. This prevents backup sprawl on startup and avoids unnecessary disk I/O.originalSnapshotofrawConfig(in-memory) before backup/write.rawConfigin memory and return; only create a backup and rewrite when content changes.Written for commit dc62243. Summary will update on new commits.