diff options
author | Shinichiro Hamaji <shinichiro.hamaji@gmail.com> | 2015-05-26 13:30:18 +0900 |
---|---|---|
committer | Shinichiro Hamaji <shinichiro.hamaji@gmail.com> | 2015-05-26 13:30:18 +0900 |
commit | 4220be3403b8eb7b352b4a9f10dbb374ecc227ed (patch) | |
tree | 4b831bb5352d97e10e9516c24db7810f0b01d51a /serialize.go | |
parent | fe1dca11d067188a117215ea24e95ee190569acd (diff) | |
download | kati-4220be3403b8eb7b352b4a9f10dbb374ecc227ed.tar.gz |
Use SHA1 hash instead of content for cache
Diffstat (limited to 'serialize.go')
-rw-r--r-- | serialize.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/serialize.go b/serialize.go index 1d414ee..6422dbe 100644 --- a/serialize.go +++ b/serialize.go @@ -2,6 +2,7 @@ package main import ( "bytes" + "crypto/sha1" "encoding/binary" "encoding/gob" "encoding/json" @@ -512,7 +513,7 @@ func showSerializedTargetsStats(targets []string) { func showSerializedReadMksStats(readMks []*ReadMakefile) { size := 0 for _, rm := range readMks { - size += len(rm.Filename) + len(rm.Content) + 4 + size += len(rm.Filename) + len(rm.Hash) + 4 } LogStats("%d makefiles %s", len(readMks), human(size)) } @@ -592,7 +593,12 @@ func LoadDepGraphCache(makefile string, roots []string) *DepGraph { } } else { c, err := readFile(mk.Filename) - if err != nil || !bytes.Equal(c, mk.Content) { + if err != nil { + LogAlways("Cache expired: %s", mk.Filename) + return nil + } + h := sha1.Sum(c) + if !bytes.Equal(h[:], mk.Hash[:]) { LogAlways("Cache expired: %s", mk.Filename) return nil } |