Skip to content

fix(dloc): apply local root paths and keep them out of the shared file - #209

Merged
ehennestad merged 2 commits into
devfrom
apply-local-data-location-root-paths
Nov 9, 2026
Merged

ehennestad merged 2 commits into
devfrom
apply-local-data-location-root-paths

Conversation

@ehennestad

@ehennestad ehennestad commented Nov 8, 2026 •

Copy link
Copy Markdown
Collaborator

Why

A data location file records the computer that created it in Preferences.SourceID. On any other computer, LocalRootPathManager is meant to keep that computer's root paths in datalocation_local_rootpath_settings.json, apply them on load, and put the source computer's paths back on save, so that the shared file does not change.

Neither direction works, for three reasons.

updateRootPathFromReference starts each iteration with if ~isempty(iSource); continue; end. iSource is one element of a struct array and is never empty, so the rest of the loop never runs.

The DataLocationModel constructor creates a second LocalRootPathManager after loading. The originals are held by the manager that did the loading, so the second one has nothing to restore on save.

hasLocalSettingsFile and loadLocalSettings derive the json path with strrep(filePath, '.mat', '.json'), which also rewrites a folder name containing .mat. On Linux the preference folder is below ~/.matlab, so the settings file is not found there.

The result on a second computer is that a save writes that computer's paths into the shared file. Reading them back on the same computer gives the expected value, so the problem shows up on the source computer, where those paths do not exist.

What changes

The guard tests iSource.RootPath, which a settings file stores as [] for a data location without root paths. The constructor no longer creates a second manager. modifyStructOnLoad already creates one when there is none. Both settings paths now come from createSettingsFilepath, which sets the extension of the file name only.

LocalRootPathManagerTest covers the manager. DataLocationModelLocalRootTest marks a model file as created on another computer and checks what reaches the shared file.

Notes for review

A shared file that already holds a second computer's paths is not repaired. Its paths have to be set again on the source computer.

This code has not run since the guard was added on 2025-10-15, so local settings files now take effect on computers that have them.

🤖 Generated with Claude Code

A computer other than the one that created a project keeps its root
paths in a local settings file. Two defects stopped this from working.

updateRootPathFromReference skipped every entry, because its guard
tested the scalar struct iSource, which is never empty. The guard now
tests iSource.RootPath, which a settings file stores as [] for a data
location without root paths. Local root paths were therefore never
applied on load, and the source computer's paths were never restored
on save, so the shared file received this computer's paths.

The DataLocationModel constructor also replaced the manager after
loading. The new manager had no record of the original root paths, so
a save had nothing to restore. Loading already creates the manager
when there is none, so the second creation is removed.

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

682 tests  +12   682 ✅ +12   1m 27s ⏱️ +20s
 56 suites + 2     0 💤 ± 0 
  1 files   ± 0     0 ❌ ± 0 

Results for commit 7d5ee76. ± Comparison against base commit f206931.

♻️ This comment has been updated with latest results.

LocalRootPathManager derived the json path with
strrep(filePath, '.mat', '.json'), which also rewrites any folder whose
name contains .mat. On Linux the preference folder is below ~/.matlab,
so the settings file was never found. Both paths now come from
createSettingsFilepath, which sets the extension of the file name only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@ehennestad ehennestad left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Checked live - works

@ehennestad
ehennestad merged commit b9bacdc into dev Nov 9, 2026
5 checks passed
@ehennestad
ehennestad deleted the apply-local-data-location-root-paths branch November 9, 2026 07:19
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