Skip to content

Issue with archives.Identify when filename contains a compression extension #7

@luotianqi777

Description

@luotianqi777

Title: Issue with archives.Identify when filename contains a compression extension

Description:

I encountered an issue while using the archives.Identify function from the github.com/mholt/archives package. When the file name includes a compression extension (e.g., test.gzero.zip), the function returns an error: gzip: invalid header.

Here is the code snippet to reproduce the issue:

package main

import (
	"context"
	"fmt"
	"os"

	"github.com/mholt/archives"
)

func main() {
	var err error
	ctx := context.Background()
	stream, _ := os.Open("testzip") // zip stream
	defer stream.Close()

	_, _, err = archives.Identify(ctx, "test.gzero.zip", stream) // filename contains Compression extension
	fmt.Println(err) // matching zip: gzip: invalid header

	_, _, err = archives.Identify(ctx, "test.zip", stream)
	fmt.Println(err) // nil
}

Steps to Reproduce:

  1. Open a zip file stream using os.Open.
  2. Pass the filename with a compression extension (e.g., test.gzero.zip) to archives.Identify.
  3. Observe that the function returns an error (gzip: invalid header).

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions