Skip to content

Commit

Permalink
fix: Addressing CodeRabbit feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
yhakbar committed Feb 27, 2025
1 parent 2a1ec1d commit 86fa996
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions internal/cas/cas.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"crypto/sha1"
"encoding/hex"
"fmt"
"io"
"log"
"os"
"path/filepath"
Expand Down Expand Up @@ -301,12 +302,18 @@ func (c *CAS) storeBlobEntries(entries []TreeEntry) error {
}

func hashFile(path string) (string, error) {
data, err := os.ReadFile(path)
file, err := os.Open(path)
if err != nil {
return "", err
}

hash := sha1.Sum(data)
defer file.Close()

return hex.EncodeToString(hash[:]), nil
h := sha1.New()

if _, err := io.Copy(h, file); err != nil {
return "", err
}

return hex.EncodeToString(h.Sum(nil)), nil
}

0 comments on commit 86fa996

Please sign in to comment.