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

Expand TranscodingStreams compat #70

Merged
merged 2 commits into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,33 @@ jobs:
fail-fast: false
matrix:
version:
- '1.6'
- '1'
- '~1.11.0-0'
- 'pre'
os:
- ubuntu-latest
- macOS-13 # intel
- macOS-14 # arm
- windows-latest
arch:
- 'x64'
- 'x86'
- 'aarch64'
exclude:
include:
- os: ubuntu-latest
arch: aarch64
- os: windows-latest
arch: aarch64
- os: macOS-13
version: '1.6'
arch: x64
- os: ubuntu-latest
version: '1.6'
arch: x86
- os: macOS-13
arch: aarch64
- os: macOS-14
arch: x86
- os: macOS-14
version: '1'
arch: x64
- os: macOS-13
version: 'pre'
arch: x64
- os: macOS-14
version: '1.6'
version: '1'
arch: aarch64
- os: macOS-14
version: 'pre'
arch: aarch64
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ ArgCheck = "2"
CodecZlib = "0.7"
InputBuffers = "1"
PrecompileTools = "1"
TranscodingStreams = "0.10.5, 0.11"
TranscodingStreams = "0.9, 0.10, 0.11"
Zlib_jll = "1"
julia = "1.6.0"
7 changes: 4 additions & 3 deletions src/writer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,11 @@ function zip_newfile(w::ZipWriter, name::AbstractString;
throw(ArgumentError("compression_method must be Deflate or Store"))
end
pe.bit_flags |= level_bits
w.transcoder = TranscodingStream(codec, io; sharedbuf=false, stop_on_end=true)
pe.method = real_compression_method

write_local_header(io, pe)
# io is a WriteOffsetTracker so it is protected from closing
# the underlying IO, or sharing buffers incorrectly.
w.transcoder = TranscodingStream(codec, io)
w.partial_entry = pe
@assert iswritable(w)
nothing
Expand Down Expand Up @@ -277,7 +278,7 @@ Base.isreadable(w::WriteOffsetTracker) = false

# All writes to the underlying IO go through this function.
# This enables ZipWriter when using zip_writefile to write to any IO that
# supports Base.unsafe_write and Base.isopen
# supports Base.unsafe_write
function Base.unsafe_write(w::WriteOffsetTracker, p::Ptr{UInt8}, n::UInt)::Int
(n > typemax(Int)) && throw(ArgumentError("too many bytes. Tried to write $n bytes"))
(w.offset < 0) && throw(ArgumentError("initial offset was negative"))
Expand Down
Loading