Repository navigation
fix(project): upgrade project catalogs and folders saved on main - #181
Open
ehennestad wants to merge 7 commits into
Open
ehennestad wants to merge 7 commits into
ehennestad wants to merge 7 commits into
Conversation
loadCatalog read ShortName from every entry. Catalogs saved on main have no such field, so the user session failed with MATLAB:nonExistentField at every start. An empty catalog without the field loaded, and then refused every new entry. loadCatalog now gives each entry the form the class uses: a missing ShortName is filled from Name, and Name, ShortName and Path are char. The isfield guard in upgradeProjects is removed, because it ran after loadCatalog had already read the field. migrateUserdata built project paths from the string that getPrefdir returns, and wrote a string Path to the catalog. backupProjectFolder concatenates that path with character vectors, which gives a string array, and mkdir refused it, so a project in main's default location never upgraded. migrateUserdata now writes a character vector, and catalogs that already hold a string are converted when loaded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
reorganizeProjectFolder removes a project from the catalog before it creates the project again in the current layout. If a later step failed, its catch block restored the folder, ignored the error and left the entry out, so the project disappeared from the catalog with no message and its upgrade was never tried again. The catalog entry is now put back and the error is rethrown. A project that was not in the catalog, as during an import, gets no entry. upgradeProjects reports the error as a warning that names the cause, and the upgrade is tried again at the next start. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Test Results669 tests 669 ✅ 1m 12s ⏱️ Results for commit 9296936. ♻️ This comment has been updated with latest results. |
The base branch no longer tracks .github/badges/tests.svg, so the generated badge is removed here as well. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The catch block in reorganizeProjectFolder restored the catalog entry first. If addProject threw there, the folder was not restored and the upgrade error was lost, although the project folder had been deleted and the catalog saved without the entry. Each step now runs when the other one fails. If either fails, the error NANSEN:ProjectManager:ProjectRollbackFailed names the backup folder, with the upgrade error as its first cause. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
conformCatalogEntries added ShortName but kept other fields, such as Preferences from main. A struct array only accepts an element with the same fields as its own, so every addProject on such a catalog threw. ShortName was also appended last, while ProjectManagerUI addresses its columns by position, so the wrong column was editable. Fields that a new entry does not have are now removed, and the fields get the order of a new entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The warning said a folder was left as it was and would be tried again. That does not hold when updateVariableCatalog fails, when the backup step fails part way, or when the rollback fails. It also gave only the innermost error message, so a failure that repeats could not be located. The warning now adds the function and line of the error, says the update is tried again only if the folder still has the old layout, and says where the backups and nansen_install are. A failed rollback reports its own message instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 project catalog saved on
mainhas the fieldsName,Description,PathandPreferences.ProjectManager.loadCatalogreadsShortNamefrom every entry, so the user session fails withMATLAB:nonExistentFieldat every start once it loads such a catalog.migrateUserdatabuilds the new path of a project kept in_userdatafrom the string thatNansenUserSession.getPrefdirreturns, and saves it to the catalog as a string.backupProjectFolderconcatenates that path with character vectors, which gives a string array, andmkdirrefuses it. A project in the default location onmainis therefore never upgraded.reorganizeProjectFolderremoves a project from the catalog before it creates the project again in the current layout. Itscatchblock restored the folder and ignored the error without putting the entry back, so a failed upgrade removed the project from the catalog with no message.Change
loadCatalogfills a missingShortNamefromName, removes fields that a new entry does not have, such asPreferences, gives the fields the order of a new entry, and convertsName,ShortNameandPathto character vectors. Catalogs already on disk then load and accept new entries. Theisfieldguard inupgradeProjectsis removed, because it ran afterloadCataloghad read the field.migrateUserdatawrites the project path as a character vector.reorganizeProjectFolderputs a removed catalog entry back, restores the project folder and rethrows the error. Each of the two steps runs when the other one fails. If either fails, it throwsNANSEN:ProjectManager:ProjectRollbackFailed, whose message names the backup folder. A project that was not in the catalog, as during an import, gets no entry unlesscreateProjecthad already added one.upgradeProjectsreports the error as a warning that names the cause and the function and line where it was raised. A folder that still has the old layout is tried again in the next MATLAB session. Each attempt makes another backup of the project folder under<userpath>/Nansen/Backup.Not changed
importProjectpasses a string toreorganizeProjectFolder, so importing a project folder in the old layout still fails inbackupProjectFolder.🤖 Generated with Claude Code