Skip to content

Calling Reader.Next() without reading file #3

Open

Description

@rHermes

Hey, thanks for a great effort on this library, as far as I can find it's the only native Go library able to read 7z files!

I was seeing some errors when trying to use it to read just a single file from a 7z archive. Turns out that you need to read all the streams in the archive, even if you are not going to use them. I don't know if this is a feature of the 7z file format or not, but I think the documentation should either be updated to make it clear that you need to read until io.EOF from the Reader before calling Next() or the code should be updated to be able to handle this.

I don't know where to start working on this, but if you can point me in a direction, I can try to submit a pull request.

Once again, thanks for a great library!

Activity

  1. saracen commented on Feb 19, 2020

    @saracen
    Owner

    Hi @rHermes

    Sorry for the delay, I've only just noticed your comment.

    The library should handle this on your behalf, however, I've had issues with the code responsible for it in the past and it won't surprise me if there's still a bug somewhere.

    When 7z uses solid blocks, multiple files are combined and compressed together. This means that when it comes to reading a specific file in the compressed block, all files compressed before it still need to be read and decompressed. The code responsible for this is actually in a separate library - github.com/saracen/solidblock - and should read and discard the unneeded data if the calling code hasn't been reading all of the files. To complicate matters, we don't just discard on each Next() call, as 7z can have multiple solid blocks, and it'd be quite wasteful to decompress and discard data in blocks the user wasn't interested in.

    I'll try to see if I can reproduce the bug and have look this week. Thank you for the report!

  2. ajnavarro commented on Jun 10, 2020

    @ajnavarro

    A tentative fix here: #5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions