Repository navigation
feat(user): run numbered migration steps on the user data directory - #211
Draft
ehennestad wants to merge 1 commit into
Draft
ehennestad wants to merge 1 commit into
ehennestad wants to merge 1 commit into
Conversation
The layout version stored in the user data directory only recorded a state. A later change that moves data needs to know which changes a directory has had, including several for someone who skipped updates. UserDataLayout.getMigrationSteps lists numbered steps, and applyMigrationSteps runs those above the stored version in order and records each as it finishes, so a chain that stops resumes where it stopped. The list is empty today: the next change that moves data adds the first step and sets CURRENT_VERSION to its number. A session refuses a directory that a newer version of NANSEN organised, because this code could write over data it does not recognise. A release that starts after the directory has moved past the first layout renames its folders instead of moving them in, so that two layouts are never mixed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
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.
Problem
A change that moves user data needs to know which earlier changes a directory has had. Someone who skipped several updates has to pass through all of them in order. The startup actions in
NansenUserSessioneach decide from what they find on disk, which cannot tell one layout from another once there are several.Change
nansen.internal.user.UserDataLayout.getMigrationStepslists numbered steps for the user data directory.nansen.internal.migration.applyMigrationStepsruns the steps above the stored version in order and records each one as it finishes. A failed step stops the session withNANSEN:Migration:StepFailed, the stored version stays at the last step that finished, and the next start resumes there.The list is empty today. The next change that moves data adds a step with
Versionone above the last, and setsCURRENT_VERSIONto that number.testCurrentVersionMatchesTheLastMigrationStepfails if the two disagree. A directory without a version file holdsFIRST_VERSION, the layout that the move out of the preference directory produces.A session stops with
NANSEN:UserSession:UserDataLayoutNewerwhen a newer version of NANSEN organised the directory, for example after checking out an older branch. The check runs before any startup action, because this code could write over data it does not recognise.What is not a step
The move out of the preference directory is not a step. Each MATLAB release has its own preference directory, so a release has to move its own data even when the shared directory is already versioned. Once the directory has passed
FIRST_VERSION, a release that starts later renames its folders to<name>.unmigratedand moves nothing, so two layouts are never mixed.The other startup actions stay as they are. The
_userdatamove belongs to an installation,moveExternalToolboxesto the add-ons, andupgradeProjectsto each project, so a version stored with the user data does not describe them.🤖 Generated with Claude Code