Skip to content

Fix OpenKh.Command.Bbsa extraction logic#1263

Open
ktheticdev wants to merge 3 commits into
OpenKH:masterfrom
ktheticdev:master
Open

Fix OpenKh.Command.Bbsa extraction logic#1263
ktheticdev wants to merge 3 commits into
OpenKH:masterfrom
ktheticdev:master

Conversation

@ktheticdev

Copy link
Copy Markdown

This fixes extraction by including files that were not extracted previously, thus fixing repacking, too. Specifically this targets the HE_205.exa file in KH BBS FM PSP release.

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Bbsa.cs is updated to read the full DirectoryEntry array upfront via a new Directory.ReadAll static helper. The Header.DirectoryEntries property gains a default empty-array initializer. The Files iterator is extended to yield entries from a new private GetDirectoryEntryTail helper that returns either all entries (when DirectoryCount == 0) or the suffix not covered by the grouped per-directory slice.

Changes

Bbsa directory entry tail enumeration

Layer / File(s) Summary
Directory.ReadAll helper, default initialization, and constructor wiring
OpenKh.Bbs/Bbsa.cs
Header.DirectoryEntries is initialized to Array.Empty<DirectoryEntry>() by default. A new Directory.ReadAll(Stream, baseOffset, count) helper reads the complete DirectoryEntry[] from stream. The Bbsa constructor now calls ReadAll to populate _header.DirectoryEntries before building the per-directory _directories objects.
Files iterator tail extension via GetDirectoryEntryTail
OpenKh.Bbs/Bbsa.cs
Files enumeration is extended to iterate over GetDirectoryEntryTail(). That helper returns all DirectoryEntries when DirectoryCount == 0, or the suffix of entries starting after index DirectoryEntriesCount / DirectoryCount * DirectoryCount, covering entries not addressed by the main grouped slice.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

Poem

🐇 Hoppin' through the archive files,
Some were hiding past the miles—
A tail of entries, skipped before,
Now the bunny finds them more!
Every file leaps from its den,
HE_205.exa runs free again! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: fixing OpenKh.Command.Bbsa extraction logic to include previously unextracted files.
Description check ✅ Passed The description is directly related to the changeset, explaining that the fix includes previously unextracted files for better extraction and repacking, specifically targeting the HE_205.exa file.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
OpenKh.Bbs/Bbsa.cs (1)

648-657: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add targeted regression tests for tail enumeration branches.

Please add coverage for: (1) DirectoryCount == 0 returns all DirectoryEntries, and (2) remainder entries are emitted when DirectoryEntriesCount % DirectoryCount != 0. This logic is central to the extraction/repack fix and should be locked in with tests.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@OpenKh.Bbs/Bbsa.cs` around lines 648 - 657, The GetDirectoryEntryTail()
method lacks regression test coverage for its critical branches. Add two unit
tests for this method: one test scenario where DirectoryCount equals zero to
verify it returns all DirectoryEntries, and a second test scenario where
DirectoryEntriesCount has a non-zero remainder when divided by DirectoryCount to
verify that the remainder entries are correctly emitted by the Skip operation.
These tests will ensure the extraction and repack logic remains stable.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@OpenKh.Bbs/Bbsa.cs`:
- Around line 648-657: The GetDirectoryEntryTail() method lacks regression test
coverage for its critical branches. Add two unit tests for this method: one test
scenario where DirectoryCount equals zero to verify it returns all
DirectoryEntries, and a second test scenario where DirectoryEntriesCount has a
non-zero remainder when divided by DirectoryCount to verify that the remainder
entries are correctly emitted by the Skip operation. These tests will ensure the
extraction and repack logic remains stable.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 81a58609-21d1-4ead-adc3-471feecc5c21

📥 Commits

Reviewing files that changed from the base of the PR and between 28e33b8 and 3be8253.

📒 Files selected for processing (1)
  • OpenKh.Bbs/Bbsa.cs

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