Skip to content

fix: load sheets in subdirectory#188

Merged
XiangYyang merged 7 commits into
theacodes:mainfrom
XiangYyang:recursive_load
Apr 26, 2026
Merged

fix: load sheets in subdirectory#188
XiangYyang merged 7 commits into
theacodes:mainfrom
XiangYyang:recursive_load

Conversation

@XiangYyang
Copy link
Copy Markdown
Collaborator

Many issues (#119, #186) report loading problems when a file references other files located in subdirectories of the repo. Consider the following directory structure

+ root.kicad_sch
+ sub
  + sub1.kicad_sch
  + sub2.kicad_sch

which schematic hierarchy is

+ root.kicad_sch
  + sub1.kicad_sch
  + sub2.kicad_sch

This currently causes an error because the existing VFS is not designed to handle tree-like directory structures. This PR refactors the VFS to support tree-structured files while maintaining backward compatibility with the older implementation. It currently refactors both GitHubVFS and DragAndDropVFS.

How it works

The idea behind the refactoring is

  1. Maintain a tree-structured list entries in FileSystemBase, which preserves the original file system hierarchy.
  2. The has function returns true if a file exists in entries.
  3. The get function loads and returns the corresponding File object.

To simplify the implementation, a new FileSystemBase abstract class is introduced. It implements all methods required by IFileSystem (referred to as VirtualFileSystem in commit 2890714). Two abstract methods are provided for constructing the file tree:

  • load_file: loads a file from a specific path
  • enumerate: lists the items in the current directory

Furthermore, to reduce the rate of API requests, it does not recursively list all files. Instead, it lists them on demand based on the directory requested by has. The repositories referenced in these issues have been verified to work correctly.

If these changes are accepted, we can proceed to implement recursive support for CodeBerg as well.

Known limits

The has function does not currently attempt to load directories with more than two levels of nesting.

+ root.kicad_sch
+ sub1
  + sub2
    + sub.kicad_sch

On the initial enumeration, entries contains only the root-level items:

root.kicad_sch
sub1

When has('sub1/sub2/sub.kicad_sch') is subsequently called, it returns false because the contents of sub1 have not yet been enumerated.

@XiangYyang XiangYyang requested a review from theacodes April 25, 2026 10:35
Copy link
Copy Markdown
Owner

@theacodes theacodes left a comment

Choose a reason for hiding this comment

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

This looks like a great improvement, thank you so much for doing this.

@XiangYyang XiangYyang merged commit 54eddb8 into theacodes:main Apr 26, 2026
2 checks passed
@XiangYyang XiangYyang deleted the recursive_load branch April 26, 2026 17:23
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.

2 participants