archive: remove unused checksum function

This commit is contained in:
Clayton Craft
2021-09-03 22:26:38 -07:00
parent 4293c887f8
commit 7bf5ce967f

View File

@@ -6,8 +6,6 @@ package archive
import (
"bytes"
"compress/flate"
"crypto/sha256"
"encoding/hex"
"github.com/cavaliercoder/go-cpio"
"github.com/klauspost/pgzip"
"gitlab.com/postmarketOS/postmarketos-mkinitfs/pkgs/misc"
@@ -59,37 +57,6 @@ func (archive *Archive) Write(path string, mode os.FileMode) error {
return nil
}
func checksum(path string) (string, error) {
var sum string
buf := make([]byte, 64*1024)
sha256 := sha256.New()
fd, err := os.Open(path)
if err != nil {
log.Print("Unable to checksum: ", path)
return sum, err
}
defer fd.Close()
// Read file in chunks
for {
bytes, err := fd.Read(buf)
if bytes > 0 {
_, err := sha256.Write(buf[:bytes])
if err != nil {
log.Print("Unable to checksum: ", path)
return sum, err
}
}
if err == io.EOF {
break
}
}
sum = hex.EncodeToString(sha256.Sum(nil))
return sum, nil
}
func (archive *Archive) AddFile(file string, dest string) error {
if err := archive.addDir(filepath.Dir(dest)); err != nil {
return err