1
0
Fork 0
forked from mirrors/tar-split

tar/asm: FileType entry with crc64 checksum

This commit is contained in:
Vincent Batts 2015-03-03 14:23:04 -05:00
parent 962589aca7
commit 4f1bde4d13
5 changed files with 121 additions and 50 deletions

View file

@ -1,6 +1,9 @@
package asm
import (
"bytes"
"fmt"
"hash/crc64"
"io"
"github.com/vbatts/tar-split/tar/storage"
@ -42,10 +45,16 @@ func NewOutputTarStream(fg FileGetter, up storage.Unpacker) io.ReadCloser {
break
}
defer fh.Close()
if _, err := io.Copy(pw, fh); err != nil {
c := crc64.New(crcTable)
tRdr := io.TeeReader(fh, c)
if _, err := io.Copy(pw, tRdr); err != nil {
pw.CloseWithError(err)
break
}
if !bytes.Equal(c.Sum(nil), entry.Payload) {
pw.CloseWithError(fmt.Errorf("file integrity checksum failed for %q", entry.Name))
break
}
}
}
}()