feat: update restore
to support InfluxDB 2.0.x (#185)
This commit is contained in:
30
pkg/gzip/gunzip.go
Normal file
30
pkg/gzip/gunzip.go
Normal file
@ -0,0 +1,30 @@
|
||||
package gzip
|
||||
|
||||
import (
|
||||
"compress/gzip"
|
||||
"io"
|
||||
)
|
||||
|
||||
func NewGunzipReadCloser(in io.ReadCloser) (*gunzipReadCloser, error) {
|
||||
gzr, err := gzip.NewReader(in)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &gunzipReadCloser{underlying: in, gunzip: gzr}, nil
|
||||
}
|
||||
|
||||
type gunzipReadCloser struct {
|
||||
underlying io.ReadCloser
|
||||
gunzip io.ReadCloser
|
||||
}
|
||||
|
||||
func (gzrc *gunzipReadCloser) Read(p []byte) (int, error) {
|
||||
return gzrc.gunzip.Read(p)
|
||||
}
|
||||
|
||||
func (gzrc *gunzipReadCloser) Close() error {
|
||||
if err := gzrc.gunzip.Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
return gzrc.underlying.Close()
|
||||
}
|
Reference in New Issue
Block a user