GHC 2023-01-09

1 comment.

, https://git.io/..... in mholt/archiver
Fails to read file from archiver.FileSystem when archive is .tar.zst
====================================================================

<!--
This template is for bug reports! (If your issue doesn't fit this template, it's probably a feature request instead.)
To fill out this template, simply replace these comments with your answers.
Please do not skip questions; this will slow down the resolution process.
-->

## What version of the package or command are you using?

v4.0.0-alpha.7

## What are you trying to do?

Extract files from a .tar.zst (zstd) archive with the `archiver.FileSystem` feature.


## What steps did you take?

Minimal reproducible example:

```go
package main

import (
	"io"
	"log"

	"github.com/mholt/archiver/v4"
)

func main() {
	archive, err := archiver.FileSystem("test.tar.zst")
	if err != nil {
		log.Fatal(err)
	}
	f, err := archive.Open("test")
	if err != nil {
		log.Fatal(err)
	}
	if _, err := io.ReadAll(f); err != nil {
		log.Fatal(err)
	}
}
```

A simple archive `test.tar.zst` with a non-empty `test` file inside it is needed, created through

```console
$ echo 12345678 > test
$ tar -cf test.tar.zst --zstd test
```

## What did you expect to happen, and what actually happened instead?
<!-- Please make it clear what the bug actually is -->

Expected successful read without error. Actually got an error from the `io.ReadAll`:

```
decoder used after Close
```

This is `ErrDecoderClosed` from the zstd module. See https://pkg.go.dev/github.com/klauspost/compress/zstd.

Note that if we use a .tar.gz instead there's no error. The problem is zstd-specific.

Also, `Tar.Extract()` works fine with .tar.zst, so this is specific to the FS implementation.

## How do you think this should be fixed?
<!-- Being specific by linking to lines of code and even suggesting changes will yield fastest resolution -->

I haven't got time to investigate yet.

## Please link to any related issues, pull requests, and/or discussion
<!-- This will help add crucial context to your report -->


## Bonus: What do you use archiver for, and do you find it useful?
<!-- We'd like to know! -->

I use it as a high level interface to archive/tar and compress/gzip, compress/zstd, etc. Saves a lot of boilerplate code.