Example #1
0
func NewFlatStatCache() *FlatStatCache {
	filename := filepath.Join(osutil.CacheDir(), "camput.statcache")
	fc := &FlatStatCache{
		filename: filename,
		m:        make(map[string]fileInfoPutRes),
		dirty:    make(map[string]fileInfoPutRes),
	}

	if f, err := os.Open(filename); err == nil {
		defer f.Close()
		d := gob.NewDecoder(f)
		for {
			var key string
			var val fileInfoPutRes
			if d.Decode(&key) != nil || d.Decode(&val) != nil {
				break
			}
			val.Pr.Skipped = true
			fc.m[key] = val
			log.Printf("Read %q: %v", key, val)
		}
		log.Printf("Flatcache read %d entries from %s", len(fc.m), filename)
	}
	return fc
}
Example #2
0
func NewFlatHaveCache() *FlatHaveCache {
	filename := filepath.Join(osutil.CacheDir(), "camput.havecache")
	c := &FlatHaveCache{
		filename: filename,
		m:        make(map[string]bool),
		dirty:    make(map[string]bool),
	}
	if f, err := os.Open(filename); err == nil {
		defer f.Close()
		d := gob.NewDecoder(f)
		for {
			var key string
			if d.Decode(&key) != nil {
				break
			}
			c.m[key] = true
		}
	}
	return c
}