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

Remove BinaryReader and BinaryWriter references from ZipArchive #103153

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Commits on Jun 4, 2024

  1. Removed BinaryReader, BinaryWriter from ZipArchive and ZipBlocks

    We now read the data into a (sometimes stack-allocated) byte array and slice it up with BinaryPrimitives.
    This reduces the number of reads and writes required to read and write a ZipArchive. It also makes future work to enable async APIs easier, since BinaryReader and BinaryWriter lack this support.
    Also changed approach to reading central file directory headers. Rather than performing X reads per header, we read 4KB of data at a time and look for all applicable headers in that data. This should improve performance when dealing with many small files.
    edwardneal committed Jun 4, 2024
    Configuration menu
    Copy the full SHA
    989e929 View commit details
    Browse the repository at this point in the history
  2. Removed BinaryReader from ZipArchiveEntry

    This allowed the removal of the ArchiveReader property from ZipArchive.
    edwardneal committed Jun 4, 2024
    Configuration menu
    Copy the full SHA
    13dee7a View commit details
    Browse the repository at this point in the history

Commits on Jun 5, 2024

  1. Configuration menu
    Copy the full SHA
    650b4f8 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    b0b8f25 View commit details
    Browse the repository at this point in the history

Commits on Jun 7, 2024

  1. Reduced memory usage with array pooling

    Now pooling the file IO buffers and the temporary buffers for extra fields of the CD file header (which would otherwise be allocated and deallocated in a loop.)
    edwardneal committed Jun 7, 2024
    Configuration menu
    Copy the full SHA
    8d1c807 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    c56ff3a View commit details
    Browse the repository at this point in the history
  3. Added test for changed central directory read method

    This handles 64x entries with 19-character filenames (and thus, 65-byte file headers.) As a result, it straddles two 4KB read buffers.
    
    Also corrected the seek logic while reading the central directory header
    edwardneal committed Jun 7, 2024
    Configuration menu
    Copy the full SHA
    9691c2a View commit details
    Browse the repository at this point in the history

Commits on Aug 8, 2024

  1. Configuration menu
    Copy the full SHA
    444b85e View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    13fc2e8 View commit details
    Browse the repository at this point in the history

Commits on Aug 9, 2024

  1. Resolving test failures

    The buffer returned from the ArrayPool contained older data (including a ZIP header.) When reading the last chunk of the file (i.e a chunk which was less than BackwardsSeekingBufferSize) the buffer's Span wasn't resized to account for this.
    SeekBackwardsToSignature would thus find the older data, try to seek beyond the end of the stream and fail to read the file.
    edwardneal committed Aug 9, 2024
    Configuration menu
    Copy the full SHA
    27c5aaf View commit details
    Browse the repository at this point in the history