Skip to content

Commit

Permalink
Improve log messages in case of error while generating the file hash
Browse files Browse the repository at this point in the history
  • Loading branch information
ste93cry committed Jul 19, 2022
1 parent 6ccab98 commit 7f43131
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions key/generator/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,21 +132,21 @@ func hashFilesFunc(logger log.Logger) func(...string) string {
func fileHash(path string, logger log.Logger) []byte {
path, err := filepath.Abs(filepath.Clean(path))
if err != nil {
level.Error(logger).Log("cache key template/checksum could not find file")
level.Error(logger).Log("could not compute the absolute file path: %s", err.Error())
return []byte{}
}

f, err := os.Open(path)
if err != nil {
level.Error(logger).Log("cache key template/checksum could not open file")
level.Error(logger).Log("could not open the file: %s", err.Error())
return []byte{}
}

defer internal.CloseWithErrLogf(logger, f, "checksum close defer")

h, err := readerHasher(f)
if err != nil {
level.Error(logger).Log("cache key template/checksum could not generate hash")
level.Error(logger).Log("could not generate the hash of the input file: %s", err.Error())
return []byte{}
}

Expand Down

0 comments on commit 7f43131

Please sign in to comment.