1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2024-12-23 00:07:25 +00:00

repository: include packID in StreamPack for decrypt/decompress errors

This commit is contained in:
Michael Eischer 2024-02-17 19:38:01 +01:00
parent 18b0bbbf42
commit 4c3218ef9f

View file

@ -1116,13 +1116,16 @@ func (b *PackBlobIterator) Next() (PackBlobValue, error) {
// decryption errors are likely permanent, give the caller a chance to skip them // decryption errors are likely permanent, give the caller a chance to skip them
nonce, ciphertext := b.buf[:b.key.NonceSize()], b.buf[b.key.NonceSize():] nonce, ciphertext := b.buf[:b.key.NonceSize()], b.buf[b.key.NonceSize():]
plaintext, err := b.key.Open(ciphertext[:0], nonce, ciphertext, nil) plaintext, err := b.key.Open(ciphertext[:0], nonce, ciphertext, nil)
if err != nil {
err = fmt.Errorf("decrypting blob %v from %v failed: %w", h, b.packID.Str(), err)
}
if err == nil && entry.IsCompressed() { if err == nil && entry.IsCompressed() {
// DecodeAll will allocate a slice if it is not large enough since it // DecodeAll will allocate a slice if it is not large enough since it
// knows the decompressed size (because we're using EncodeAll) // knows the decompressed size (because we're using EncodeAll)
b.decode, err = b.dec.DecodeAll(plaintext, b.decode[:0]) b.decode, err = b.dec.DecodeAll(plaintext, b.decode[:0])
plaintext = b.decode plaintext = b.decode
if err != nil { if err != nil {
err = errors.Errorf("decompressing blob %v failed: %v", h, err) err = fmt.Errorf("decompressing blob %v from %v failed: %w", h, b.packID.Str(), err)
} }
} }
if err == nil { if err == nil {