archive: remove unused checksum function
This commit is contained in:
@@ -6,8 +6,6 @@ package archive
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"compress/flate"
|
"compress/flate"
|
||||||
"crypto/sha256"
|
|
||||||
"encoding/hex"
|
|
||||||
"github.com/cavaliercoder/go-cpio"
|
"github.com/cavaliercoder/go-cpio"
|
||||||
"github.com/klauspost/pgzip"
|
"github.com/klauspost/pgzip"
|
||||||
"gitlab.com/postmarketOS/postmarketos-mkinitfs/pkgs/misc"
|
"gitlab.com/postmarketOS/postmarketos-mkinitfs/pkgs/misc"
|
||||||
@@ -59,37 +57,6 @@ func (archive *Archive) Write(path string, mode os.FileMode) error {
|
|||||||
return nil
|
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 {
|
func (archive *Archive) AddFile(file string, dest string) error {
|
||||||
if err := archive.addDir(filepath.Dir(dest)); err != nil {
|
if err := archive.addDir(filepath.Dir(dest)); err != nil {
|
||||||
return err
|
return err
|
||||||
|
Reference in New Issue
Block a user