Skip to content

Conversation

@shananas
Copy link
Collaborator

@shananas shananas commented Jan 7, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Improved ZIP extraction logic in the Mods Manager to more reliably identify and process file entries inside archives, ensuring mod installations from compressed packages succeed and include the correct files.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 7, 2026

📝 Walkthrough

Walkthrough

Changed ZIP extraction logic in ModsService.cs to include ZipArchiveEntry items only when entry.Name is non-empty, replacing the previous ExternalAttributes-based directory detection. No other extraction or metadata logic was altered.

Changes

Cohort / File(s) Summary
ZIP Entry Filter Update
OpenKh.Tools.ModsManager/Services/ModsService.cs
Replaced ZIP extraction loop condition from checking (ExternalAttributes & 0x10) != 0x10 to selecting entries where entry.Name is non-empty, altering which archive entries are processed during mod installation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰
A rabbit hopped through ZIPs today,
Switched a filter along the way,
Now names that exist get their say,
Empty names no longer play,
Hooray for clearer paths to stray! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 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 (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly addresses the main change: fixing an issue where Windows 11 ZIP files cause errors during mod manager installation by updating the ZIP entry filter logic.

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

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 126f362 and 554728e.

📒 Files selected for processing (1)
  • OpenKh.Tools.ModsManager/Services/ModsService.cs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build
  • GitHub Check: Analyze (csharp)
🔇 Additional comments (2)
OpenKh.Tools.ModsManager/Services/ModsService.cs (2)

245-245: Consistent filtering applied to metadata generation loop.

The same filtering logic is correctly applied here to ensure only file entries are processed when generating Asset metadata for KH patch files. This maintains consistency with the extraction loop at line 176.


176-176: ZIP entry filtering correctly excludes directory entries.

The change from ExternalAttributes-based detection to Name-based filtering is correct and addresses the Windows 11 ZIP compatibility issue. The ZipArchiveEntry.Name property is reliably empty for directory entries across all platforms and ZIP file sources, making it a more portable alternative to the platform-dependent ExternalAttributes bit check. Both occurrences at lines 176 and 245 consistently apply the same filter, and the extraction logic properly handles the filtered file entries by creating directories from FullName as needed before writing file contents.


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 and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
OpenKh.Tools.ModsManager/Services/ModsService.cs (1)

245-245: Update this filter to match the new logic at line 176.

Line 245 still uses the old ExternalAttributes-based directory filtering that was replaced at line 176. If Windows 11 ZIP files have incorrect ExternalAttributes (which motivated the fix at line 176), this section will also fail or produce incorrect metadata.

For consistency and correctness, update this filter to match line 176's approach:

🔧 Proposed fix to align filtering logic
-foreach (var entry in zipFile.Entries.Where(x => (x.ExternalAttributes & 0x10) != 0x10))
+foreach (var entry in zipFile.Entries.Where(x => !string.IsNullOrEmpty(x.Name)))

Or use the more robust version if you adopt the suggested improvement from line 176:

-foreach (var entry in zipFile.Entries.Where(x => (x.ExternalAttributes & 0x10) != 0x10))
+foreach (var entry in zipFile.Entries.Where(x => !string.IsNullOrEmpty(x.Name) && !x.FullName.EndsWith("/") && !x.FullName.EndsWith("\\")))
🧹 Nitpick comments (1)
OpenKh.Tools.ModsManager/Services/ModsService.cs (1)

176-176: Verify that Name-based filtering reliably excludes all directory entries.

The change from ExternalAttributes-based filtering to checking !string.IsNullOrEmpty(x.Name) may resolve issues with Windows 11 ZIP files, but could be fragile across different ZIP implementations. Directory entries typically have an empty Name property, but this isn't guaranteed by the ZIP specification.

Consider a more robust check that also verifies FullName doesn't end with a path separator:

foreach (var entry in zipFile.Entries.Where(x => !string.IsNullOrEmpty(x.Name) && !x.FullName.EndsWith("/") && !x.FullName.EndsWith("\\")))

This would prevent attempting to create a file (line 199) for any directory entries that slip through with a non-empty Name.

Please verify this fix with actual Windows 11 ZIP files to ensure:

  1. Directory entries are correctly excluded
  2. All expected file entries are extracted
  3. No File.Create errors occur on directory paths
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ca0223a and 126f362.

📒 Files selected for processing (1)
  • OpenKh.Tools.ModsManager/Services/ModsService.cs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Analyze (csharp)
  • GitHub Check: build

@shananas shananas merged commit 22b5450 into OpenKH:master Jan 8, 2026
4 checks passed
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