Files
steam-immich/internal/hasher.go

32 lines
459 B
Go

package steamimmich
import (
"crypto/sha1"
"fmt"
"io"
"os"
)
func hashFiles(assets []AssetState) (map[int]string, error) {
results := make(map[int]string)
for i, p := range assets {
f, err := os.Open(p.FilePath)
if err != nil {
results[i] = ""
continue
}
h := sha1.New()
if _, err := io.Copy(h, f); err != nil {
f.Close()
return nil, err
}
f.Close()
results[i] = fmt.Sprintf("%x", h.Sum(nil))
}
return results, nil
}