mirror of
https://github.com/restic/restic.git
synced 2025-05-17 11:28:22 +00:00
debug: Add support for compressed blobs
This commit is contained in:
parent
fda7bb0f09
commit
2535524132
@ -15,6 +15,7 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/klauspost/compress/zstd"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
|
|
||||||
@ -309,6 +310,10 @@ func decryptUnsigned(ctx context.Context, k *crypto.Key, buf []byte) []byte {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func loadBlobs(ctx context.Context, repo restic.Repository, pack restic.ID, list []restic.Blob) error {
|
func loadBlobs(ctx context.Context, repo restic.Repository, pack restic.ID, list []restic.Blob) error {
|
||||||
|
dec, err := zstd.NewReader(nil)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
be := repo.Backend()
|
be := repo.Backend()
|
||||||
h := restic.Handle{
|
h := restic.Handle{
|
||||||
Name: pack.String(),
|
Name: pack.String(),
|
||||||
@ -353,6 +358,16 @@ func loadBlobs(ctx context.Context, repo restic.Repository, pack restic.ID, list
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if blob.IsCompressed() {
|
||||||
|
decompressed, err := dec.DecodeAll(plaintext, nil)
|
||||||
|
if err != nil {
|
||||||
|
Printf(" failed to decompress blob %v\n", blob.ID)
|
||||||
|
}
|
||||||
|
if decompressed != nil {
|
||||||
|
plaintext = decompressed
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
id := restic.Hash(plaintext)
|
id := restic.Hash(plaintext)
|
||||||
var prefix string
|
var prefix string
|
||||||
if !id.Equal(blob.ID) {
|
if !id.Equal(blob.ID) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user