Skip to content

Fix LocalFileIdentifiableStore.__len__ to count only .json store files#507

Open
zrgt wants to merge 1 commit intoeclipse-basyx:developfrom
rwth-iat:fix/b10-local-file-len
Open

Fix LocalFileIdentifiableStore.__len__ to count only .json store files#507
zrgt wants to merge 1 commit intoeclipse-basyx:developfrom
rwth-iat:fix/b10-local-file-len

Conversation

@zrgt
Copy link
Copy Markdown
Contributor

@zrgt zrgt commented May 5, 2026

Fixes #503

Changes

  • __len__ now counts only .json files in the store directory, ignoring hidden files (.DS_Store), temp files, and subdirectories
  • Add test_len_ignores_non_json_files unit test

"""
logger.debug("Fetching number of documents from database ...")
return len(os.listdir(self.directory_path))
return sum(1 for f in os.listdir(self.directory_path) if f.endswith(".json"))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That's not enough though is it? In theory it could also be ".JSON". Of course only when added manually and not by our code.
However, if we ever decide to add objects to the store as .JSON files, this will fail silently.

@s-heppner
Copy link
Copy Markdown
Member

Actually: Instead of adding support for .JSON, how about we ensure in a unittest that __add__ and __len__ work together?

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