Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit ca7993e

Browse files
committed
port to github/pierrec/lz4/v4
Resolves #248 . Minimum lang version needs to be bumped to 1.13, otherwise we get this error: ./lz4.go:20:53: invalid operation: 1 << (8 + lz.CompressionLevel) (signed shift count type int) requires go1.13 or later (-lang was set to go1.12; check go.mod) ./tarlz4.go:88:54: invalid operation: 1 << (8 + tlz4.CompressionLevel) (signed shift count type int) requires go1.13 or later (-lang was set to go1.12; check go.mod)
1 parent 858e52c commit ca7993e

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/mholt/archiver/v3
22

3-
go 1.12
3+
go 1.13
44

55
require (
66
github.com/andybalholm/brotli v1.0.0
@@ -12,7 +12,7 @@ require (
1212
github.com/klauspost/pgzip v1.2.4
1313
github.com/kr/text v0.2.0 // indirect
1414
github.com/nwaples/rardecode v1.1.0
15-
github.com/pierrec/lz4/v3 v3.3.2
15+
github.com/pierrec/lz4/v4 v4.0.3
1616
github.com/ulikunitz/xz v0.5.7
1717
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8
1818
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W
4545
github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
4646
github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
4747
github.com/pierrec/cmdflag v0.0.2/go.mod h1:a3zKGZ3cdQUfxjd0RGMLZr8xI3nvpJOB+m6o/1X5BmU=
48-
github.com/pierrec/lz4/v3 v3.3.2 h1:QTUOCbMNDbK4PYtkuHyOBd28C0UhPBw3T4OH4WpFDik=
49-
github.com/pierrec/lz4/v3 v3.3.2/go.mod h1:280XNCGS8jAcG++AHdd6SeWnzyJ1w9oow2vbORyey8Q=
48+
github.com/pierrec/lz4/v4 v4.0.3 h1:vNQKSVZNYUEAvRY9FaUXAF1XPbSOHJtDTiP41kzDz2E=
49+
github.com/pierrec/lz4/v4 v4.0.3/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
5050
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
5151
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
5252
github.com/schollz/progressbar/v2 v2.13.2/go.mod h1:6YZjqdthH6SCZKv2rqGryrxPtfmRB/DWZxSMfCXPyD8=

lz4.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"io"
66
"path/filepath"
77

8-
"github.com/pierrec/lz4/v3"
8+
"github.com/pierrec/lz4/v4"
99
)
1010

1111
// Lz4 facilitates LZ4 compression.
@@ -16,7 +16,12 @@ type Lz4 struct {
1616
// Compress reads in, compresses it, and writes it to out.
1717
func (lz *Lz4) Compress(in io.Reader, out io.Writer) error {
1818
w := lz4.NewWriter(out)
19-
w.Header.CompressionLevel = lz.CompressionLevel
19+
options := []lz4.Option{
20+
lz4.CompressionLevelOption(lz4.CompressionLevel(1 << (8 + lz.CompressionLevel))),
21+
}
22+
if err := w.Apply(options...); err != nil {
23+
return err
24+
}
2025
defer w.Close()
2126
_, err := io.Copy(w, in)
2227
return err

tarlz4.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"io"
66
"strings"
77

8-
"github.com/pierrec/lz4/v3"
8+
"github.com/pierrec/lz4/v4"
99
)
1010

1111
// TarLz4 facilitates lz4 compression
@@ -84,7 +84,12 @@ func (tlz4 *TarLz4) wrapWriter() {
8484
var lz4w *lz4.Writer
8585
tlz4.Tar.writerWrapFn = func(w io.Writer) (io.Writer, error) {
8686
lz4w = lz4.NewWriter(w)
87-
lz4w.Header.CompressionLevel = tlz4.CompressionLevel
87+
options := []lz4.Option{
88+
lz4.CompressionLevelOption(lz4.CompressionLevel(1 << (8 + tlz4.CompressionLevel))),
89+
}
90+
if err := lz4w.Apply(options...); err != nil {
91+
return lz4w, err
92+
}
8893
return lz4w, nil
8994
}
9095
tlz4.Tar.cleanupWrapFn = func() {

0 commit comments

Comments
 (0)