Exctraction Edge Case#1259
Conversation
… moved, or the filepath is no longer correct for some other reason
📝 WalkthroughWalkthroughWhen extracting PC game data, the ViewModel now derives a local ChangesPC Edition Extraction Logic
ConfigurationService: GamesToExtract Cleanup
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ 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. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
There was a problem hiding this comment.
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/ViewModels/SetupWizardViewModel.cs (1)
1861-1884:⚠️ Potential issue | 🟠 Major | ⚡ Quick winGuard the empty PC-release case before calling extraction.
If the selected install was moved or uninstalled, these gates can make every extraction flag
false, butExtractKhPcEditionAsyncstill enters itsonProgress(0)path and never reaches a completion update. That leaves the wizard stuck in the busy state with no feedback.Suggested fix
var langFolder = ConfigurationService.PCVersion == "Steam" ? "dt" : _pcReleaseLanguage == "jp" ? "jp" : "en"; string GamesFound = PcReleaseSelections; + if (string.IsNullOrEmpty(GamesFound)) + { + MessageBox.Show( + "No valid PC release was found. Please reselect the install directory before extracting.", + "Extraction error", + MessageBoxButton.OK, + MessageBoxImage.Warning); + return; + } await _gameDataExtractionService.ExtractKhPcEditionAsync(
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 31702327-06ba-4979-9656-93e072efe092
📒 Files selected for processing (1)
OpenKh.Tools.ModsManager/ViewModels/SetupWizardViewModel.cs
… extract if more than 1 was manually added. Move previous fix to earlier.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
OpenKh.Tools.ModsManager/Services/ConfigurationService.cs (1)
495-503: ⚡ Quick win
Addon thetruebranch is still unconditional — duplicates can re-accumulate.Each setter's
truebranch calls_config.GamesToExtract.Add(...)without aContainsguard. If the setter is invoked withtruemore than once (e.g., wizard re-entered), a duplicate entry is appended again.RemoveAllwill clean it up on the nextfalseassignment, but the persisted YAML will accumulate duplicates in the meantime, which is precisely the problem this PR is solving.The minimal fix is a
Containscheck beforeAdd; a stronger fix is to makeGamesToExtractaHashSet<string>(requires a YAML-serialization-compatible wrapper) or deduplicate on load.♻️ Proposed fix (guard Add with Contains — example for all five setters)
if (value) { - _config.GamesToExtract.Add("kh1"); + if (!_config.GamesToExtract.Contains("kh1")) + _config.GamesToExtract.Add("kh1"); }Apply the same pattern for
"kh2","bbs","Recom", and"kh3d".Also applies to: 511-519, 527-535, 543-551, 559-567
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@OpenKh.Tools.ModsManager/Services/ConfigurationService.cs` around lines 495 - 503, The setter code in ConfigurationService.cs unconditionally calls _config.GamesToExtract.Add(...) (e.g., for "kh1", and similarly for "kh2","bbs","Recom","kh3d") which allows duplicate entries to accumulate; modify each setter so that before calling _config.GamesToExtract.Add("...") you check if !_config.GamesToExtract.Contains("...") and only then add, then still call _config.Save(ConfigPath); apply this guard to all five setters (the blocks currently manipulating _config.GamesToExtract for "kh1","kh2","bbs","Recom","kh3d") to prevent duplicate entries being persisted.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@OpenKh.Tools.ModsManager/Services/ConfigurationService.cs`:
- Around line 495-503: The setter code in ConfigurationService.cs
unconditionally calls _config.GamesToExtract.Add(...) (e.g., for "kh1", and
similarly for "kh2","bbs","Recom","kh3d") which allows duplicate entries to
accumulate; modify each setter so that before calling
_config.GamesToExtract.Add("...") you check if
!_config.GamesToExtract.Contains("...") and only then add, then still call
_config.Save(ConfigPath); apply this guard to all five setters (the blocks
currently manipulating _config.GamesToExtract for
"kh1","kh2","bbs","Recom","kh3d") to prevent duplicate entries being persisted.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 0e10df05-ad60-40ff-9668-2c39798bd7f7
📒 Files selected for processing (2)
OpenKh.Tools.ModsManager/Services/ConfigurationService.csOpenKh.Tools.ModsManager/ViewModels/SetupWizardViewModel.cs
🚧 Files skipped from review as they are similar to previous changes (1)
- OpenKh.Tools.ModsManager/ViewModels/SetupWizardViewModel.cs
Dont extract a game if it was checked but has since been uninstalled, moved, or the filepath is no longer correct for some other reason