Skip to content

fix(project): upgrade project catalogs and folders saved on main - #181

Open
ehennestad wants to merge 7 commits into
devfrom
fix-catalog-upgrade-from-main
Open

ehennestad wants to merge 7 commits into
devfrom
fix-catalog-upgrade-from-main

Conversation

@ehennestad

@ehennestad ehennestad commented Nov 8, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

A project catalog saved on main has the fields Name, Description, Path and Preferences. ProjectManager.loadCatalog reads ShortName from every entry, so the user session fails with MATLAB:nonExistentField at every start once it loads such a catalog.

migrateUserdata builds the new path of a project kept in _userdata from the string that NansenUserSession.getPrefdir returns, and saves it to the catalog as a string. backupProjectFolder concatenates that path with character vectors, which gives a string array, and mkdir refuses it. A project in the default location on main is therefore never upgraded.

reorganizeProjectFolder removes a project from the catalog before it creates the project again in the current layout. Its catch block 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

loadCatalog fills a missing ShortName from Name, removes fields that a new entry does not have, such as Preferences, gives the fields the order of a new entry, and converts Name, ShortName and Path to character vectors. Catalogs already on disk then load and accept new entries. The isfield guard in upgradeProjects is removed, because it ran after loadCatalog had read the field.

migrateUserdata writes the project path as a character vector.

reorganizeProjectFolder puts 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 throws NANSEN:ProjectManager:ProjectRollbackFailed, whose message names the backup folder. A project that was not in the catalog, as during an import, gets no entry unless createProject had already added one.

upgradeProjects reports 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

importProject passes a string to reorganizeProjectFolder, so importing a project folder in the old layout still fails in backupProjectFolder.

🤖 Generated with Claude Code

ehennestad and others added 2 commits November 8, 2026 09:49
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>
@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Test Results

669 tests   669 ✅  1m 12s ⏱️
 53 suites    0 💤
  1 files      0 ❌

Results for commit 9296936.

♻️ This comment has been updated with latest results.

@ehennestad
ehennestad added this pull request to stack #187 November 8, 2026 08:57
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>
@ehennestad ehennestad self-assigned this Nov 8, 2026
ehennestad and others added 3 commits November 8, 2026 17:20
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant