MCPcopy Index your code
hub / github.com/aptly-dev/aptly / MD5ChecksumForFile

Function MD5ChecksumForFile

utils/checksum.go:15–31  ·  view source on GitHub ↗

MD5ChecksumForFile computes just the MD5 hash and not all the others

(path string)

Source from the content-addressed store, hash-verified

13
14// MD5ChecksumForFile computes just the MD5 hash and not all the others
15func MD5ChecksumForFile(path string) (string, error) {
16 file, err := os.Open(path)
17 if err != nil {
18 return "", err
19 }
20 defer func() {
21 _ = file.Close()
22 }()
23
24 hash := md5.New()
25 _, err = io.Copy(hash, file)
26 if err != nil {
27 return "", err
28 }
29
30 return fmt.Sprintf("%x", hash.Sum(nil)), nil
31}
32
33// ChecksumInfo represents checksums for a single file
34type ChecksumInfo struct {

Callers 3

LinkFromPoolMethod · 0.92
PutFileMethod · 0.92

Calls 4

SumMethod · 0.80
OpenMethod · 0.65
CloseMethod · 0.65
CopyMethod · 0.45

Tested by 1