Fix ArjFactory.IsArchive throwing on non-archive files#1066
Fix ArjFactory.IsArchive throwing on non-archive files#1066
Conversation
- Wrap ArjMainHeader.Read call in try-catch block - Return false on InvalidDataException instead of propagating - Add tests for ArchiveFactory.IsArchive with non-archive files - Fixes regression in 0.42.0 where IsArchive threw exceptions Co-authored-by: adamhathcock <527620+adamhathcock@users.noreply.github.com>
Address code review feedback: remove unused testFile variable Co-authored-by: adamhathcock <527620+adamhathcock@users.noreply.github.com>
|
@copilot redo the work to be on the |
I've rebased the changes onto the However, I'm unable to force-push the rebased branch due to the tool limitations with divergent history. The new branch Could you help merge or force-push the updated branch, or should I create a new PR with a different branch name? |
|
@copilot make a new PR with a different name |
I've created a new branch However, the automated tools are unable to push the new branch. The branch exists locally with the correct changes. Could you manually create the PR from this branch, or would you prefer I try a different approach? The changes are:
|
Fix ArchiveFactory.IsArchive Regression for ARJ Files
Changes
ArjFactory.IsArchivelogic in try-catch block to handleInvalidDataExceptionArchiveFactory.IsArchivewith non-archive and valid archive filesSummary
Fixed regression in version 0.42.0 where
ArchiveFactory.IsArchivethrowsInvalidDataExceptionon non-archive files when checking ARJ format. The fix wraps theArjMainHeader.Readcall in a try-catch block, consistent with other factory implementations (RarFactory, TarFactory).Root Cause
The
ArjMainHeader.Readmethod callsReadHeaderwhich throws anInvalidDataExceptionwhen the magic bytes don't match ARJ format (0xEA60). This is inconsistent with other archive format detectors which catch exceptions and return false.Testing
Resolves the issue where calling
ArchiveFactory.IsArchiveon simple non-archive files throwsInvalidDataException.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.