add lz4
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
package restore
|
||||
|
||||
import (
|
||||
"compress/gzip"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -15,6 +14,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/mistifyio/go-zfs"
|
||||
"github.com/pierrec/lz4/v4"
|
||||
)
|
||||
|
||||
// SnapshotMetadata represents snapshot information from the server.
|
||||
@@ -97,7 +97,7 @@ func (c *Client) DisplaySnapshots(snapshots []*SnapshotMetadata) {
|
||||
sizeGB := float64(snap.SizeBytes) / (1024 * 1024 * 1024)
|
||||
compressed := ""
|
||||
if snap.Compressed {
|
||||
compressed = " (gz)"
|
||||
compressed = " (lz4)"
|
||||
}
|
||||
|
||||
fmt.Printf("%-4d %-25s %-20s %7.2f GB %-10s %s%s\n",
|
||||
@@ -154,13 +154,9 @@ func (c *Client) RestoreSnapshot(snapshot *SnapshotMetadata, targetDataset strin
|
||||
// Create decompression reader if needed
|
||||
var reader io.Reader = resp.Body
|
||||
if snapshot.Compressed {
|
||||
fmt.Printf(" Decompressing...\n")
|
||||
gzReader, err := gzip.NewReader(resp.Body)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create gzip reader: %v", err)
|
||||
}
|
||||
defer gzReader.Close()
|
||||
reader = gzReader
|
||||
fmt.Printf(" Decompressing with LZ4...\n")
|
||||
lz4Reader := lz4.NewReader(resp.Body)
|
||||
reader = lz4Reader
|
||||
}
|
||||
|
||||
// Receive into ZFS
|
||||
|
||||
Reference in New Issue
Block a user