Skip to content

fix(file-list): correct recursive file listing #456

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jul 22, 2025

Conversation

sanjayankur31
Copy link
Member

When there are models that follow a recursive structure. For example:

something.net.nml -> ./cells/cell.nml -> ./channels/channel.nml

When processing the cell.nml file, we must do it relative to its location, not relative to the root file (something.net.nml) so that the paths are correct in the final list of files included in the model.

We do this by making sure that when recursing through the list, we pass the location of the "new" rootfile, and when we append the processed file to the file list, we include its "rootdir", which would be relevant to the "main" rootfile.

When there are models that follow a recursive structure. For example:

```
something.net.nml -> ./cells/cell.nml -> ./channels/channel.nml
```

When processing the cell.nml file, we must do it relative to its
location, not relative to the root file (something.net.nml) so that the
paths are correct in the final list of files included in the model.

We do this by making sure that when recursing through the list, we pass
the location of the "new" rootfile, and when we append the processed
file to the file list, we include its "rootdir", which would be relevant
to the "main" rootfile.
Scenario 1:

Function is called from the directory where the "rootfile" lives.
This is simple, as all the files will have includes relative to this
directory. However, we do need to handle recursion because models and
includes can be split into any numbers of folders/levels.

Scenario 2:

Function is not called from the directory where the "rootfile" lives.
The directory is specified as the "rootdir". Here, we need to append the
rootdir to all the includes also so that they can be correctly found.

This case is not suggested, especially for archiving.
We now move all the folder bits to the rootdir, and keep the rootfile
only as the name. This simplifies further processing, especially passing
the folders to the recursively included files.
@sanjayankur31 sanjayankur31 marked this pull request as ready for review July 22, 2025 15:18
@sanjayankur31 sanjayankur31 merged commit 616b7fe into development Jul 22, 2025
1 check passed
@sanjayankur31 sanjayankur31 deleted the fix-filelist branch July 22, 2025 15:22
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