archive/checksum: do not try to close fd if open() failed

See #6
This commit is contained in:
Clayton Craft
2021-09-03 21:19:11 -07:00
parent 9c7e647f9e
commit 13a3ba36bd

View File

@@ -64,12 +64,11 @@ func checksum(path string) (string, error) {
buf := make([]byte, 64*1024)
sha256 := sha256.New()
fd, err := os.Open(path)
defer fd.Close()
if err != nil {
log.Print("Unable to checksum: ", path)
return sum, err
}
defer fd.Close()
// Read file in chunks
for {