// It's a superset of the "bad characters" on other OSes, so this works.
var badPath = regexp.MustCompile(`[\\/:\*\?\"<>\|]`)
-func stringify(stuff ...CacheKey) []string {
+func Stringify(stuff ...CacheKey) []string {
ret := make([]string, len(stuff))
for i := range stuff {
s := fmt.Sprint(stuff[i])
// This also means that cache keys that are file-backed
// cannot have subkeys.
func (cd *CacheDir) cachePath(key ...CacheKey) string {
- parts := append([]string{cd.GetCacheDir()}, stringify(key...)...)
+ parts := append([]string{cd.GetCacheDir()}, Stringify(key...)...)
p := filepath.Join(filterDots(parts...)...)
return p
}
func (cd *CacheDir) GetInvalid(key ...CacheKey) (ts time.Time) {
invKey := append(invalidPath, key...)
- stat, _ := cd.Stat(invKey...)
- return stat.ModTime()
+ if stat, err := cd.Stat(invKey...); err == nil {
+ ts = stat.ModTime()
+ }
+ return
}
// Checks if the given key is not marked as invalid, or if it is,