Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better error handling #41

Merged
merged 3 commits into from
Dec 17, 2024
Merged

Better error handling #41

merged 3 commits into from
Dec 17, 2024

Conversation

nhz2
Copy link
Member

@nhz2 nhz2 commented Dec 17, 2024

Fixes #32 Fixes #36

This fixes #36 by porting the fix in JuliaIO/CodecZlib.jl#62 to this package.

The descriptions of the errors are from https://sourceware.org/bzip2/manual/manual.html#err-handling

The bzip2 manual doesn't explicitly describe how to check for truncated streams to fix #32 so I am using the method used in BZ2_bzRead in bzlib.c line 1204 from bzip2 v1.0.8:

      if (ret == BZ_OK && myfeof(bzf->handle) && 
          bzf->strm.avail_in == 0 && bzf->strm.avail_out > 0)
         { BZ_SETERR(BZ_UNEXPECTED_EOF); return 0; };

Here the input size being zero is used by Transcodingstreams to signal the end of the input stream.

    if code == BZ_OK
        if iszero(input.size) && !iszero(stream.avail_out)
            error[] = BZ2Error(BZ_UNEXPECTED_EOF)
            return Δin, Δout, :error
        else
            return Δin, Δout, :ok
        end

Copy link

codecov bot commented Dec 17, 2024

Codecov Report

Attention: Patch coverage is 66.66667% with 23 lines in your changes missing coverage. Please review.

Project coverage is 82.63%. Comparing base (5ce971b) to head (4866eeb).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/compression.jl 50.00% 11 Missing ⚠️
src/decompression.jl 60.71% 11 Missing ⚠️
src/libbzip2.jl 94.73% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #41      +/-   ##
==========================================
- Coverage   84.92%   82.63%   -2.29%     
==========================================
  Files           4        4              
  Lines         126      167      +41     
==========================================
+ Hits          107      138      +31     
- Misses         19       29      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nhz2 nhz2 marked this pull request as ready for review December 17, 2024 16:58
@nhz2 nhz2 merged commit 95a9fc8 into master Dec 17, 2024
12 of 14 checks passed
@nhz2 nhz2 deleted the nz/better-errors branch December 17, 2024 19:20
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.

Unable to transcode more than typemax(UInt32) bytes Corrupt files hang in makemargin!
1 participant