fix(core): add null checks before closing BinaryReader/FileStream in update process#6507
fix(core): add null checks before closing BinaryReader/FileStream in update process#6507mertemr wants to merge 1 commit intoScoopInstaller:developfrom
Conversation
WalkthroughAdds null checks in Get-PESubsystem’s finally block within lib/core.ps1 to verify $binaryReader and $fileStream are non-null before calling Close(). No other logic or control flow changes. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🔇 Additional comments (1)
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. Comment |
There was a problem hiding this comment.
Pull Request Overview
This PR fixes InvalidOperation exceptions that occur when running scoop update in PowerShell 7 by adding null checks before closing BinaryReader and FileStream objects in the Get-PESubsystem function.
- Added null checks for
$binaryReaderand$fileStreamvariables before calling theirClose()methods - Prevents exceptions when these objects are null during the cleanup process in the finally block
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Description
This PR adds null checks for $binaryReader and $fileStream in
core.ps1to prevent InvalidOperation exceptions when running scoop update.Motivation and Context
Running scoop update in PowerShell 7 consistently threw InvalidOperation errors because Close() was called on null objects.
This change ensures the objects are checked before attempting to close them.
Fixes #6506
How Has This Been Tested?
scoop update -ano longer throws InvalidOperation exceptions.Checklist:
developbranch.Summary by CodeRabbit