Skip to content

archive/zip: (*File).Open is inconsistent with (*Reader).Open for directory entries #58165

Description

@bcmills

What version of Go are you using (go version)?

https://pkg.go.dev/archive/zip@go1.20rc3

Does this issue reproduce with the latest release?

Yes

What did you do?

(https://go.dev/play/p/NFjouX0xrQk?v=gotip)

  1. Create a zip archive containing a directory entry.
  2. Open a zip.Reader for that archive.
  3. Open the zip.File for the directory entry using (*zip.Reader).Open and Read it.
  4. Open the zip.File for the directory by calling (*zip.File).Open and Read it.

What did you expect to see?

The same contents (and same error code) regardless of how the directory entry was opened.

What did you see instead?

The reader opened via (*zip.Reader).Open returns a non-nil error like read dir: is a directory.
The reader opened via (*zip.File).Open returns 0, io.EOF.

(attn @dsnet @bradfitz; CC @neild)

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions