Repository navigation
fix(dloc): apply local root paths and keep them out of the shared file - #209
Merged
Merged
Conversation
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>
Contributor
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
commented
Nov 9, 2026
ehennestad
left a comment
Collaborator
Author
There was a problem hiding this comment.
Looks good. Checked live - works
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.
Why
A data location file records the computer that created it in
Preferences.SourceID. On any other computer,LocalRootPathManageris meant to keep that computer's root paths indatalocation_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.
updateRootPathFromReferencestarts each iteration withif ~isempty(iSource); continue; end.iSourceis one element of a struct array and is never empty, so the rest of the loop never runs.The
DataLocationModelconstructor creates a secondLocalRootPathManagerafter loading. The originals are held by the manager that did the loading, so the second one has nothing to restore on save.hasLocalSettingsFileandloadLocalSettingsderive the json path withstrrep(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.modifyStructOnLoadalready creates one when there is none. Both settings paths now come fromcreateSettingsFilepath, which sets the extension of the file name only.LocalRootPathManagerTestcovers the manager.DataLocationModelLocalRootTestmarks 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