Skip to content

fix: skip non-directory entries in listScopeIds - #18

Open
yulong-ge wants to merge 1 commit into
different-ai:mainfrom
yulong-ge:fix/scope-listing-skip-non-dirs
Open

fix: skip non-directory entries in listScopeIds#18
yulong-ge wants to merge 1 commit into
different-ai:mainfrom
yulong-ge:fix/scope-listing-skip-non-dirs

Conversation

@yulong-ge

Copy link
Copy Markdown

Problem

listScopeIds() treats every entry returned by readdirSync as a scope ID. On macOS, Finder writes .DS_Store files into the scopes root; any plain file that happens to share the directory would also be mis-identified. This causes downstream operations (job loading, storage init) to fail or produce unexpected results.

Changes

  • listScopeIds(): Use readdirSync(root, { withFileTypes: true }) and filter by entry.isDirectory() instead of probing each name with existsSync(scopeDir(name)).
  • ensureScopeStorage(): Add a guard — if the resolved scope path exists but is not a directory, return early instead of trying to create sub-dirs inside a file.
  • Export listScopeIds with an optional root parameter so it can be unit-tested against temp directories.
  • Add unit tests covering: missing dir, empty dir, normal scopes, .DS_Store, stray files, mixed entries, no-throw guarantee.

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