cache/filecache: Add a :project placeholder

This allows for "cache per Hugo project", making `hugo --gc` work as expected, even if you have several Hugo projects running on the same PC.

See #5439
This commit is contained in:
Bjørn Erik Pedersen
2018-11-14 17:18:32 +01:00
parent 3c29c5af8e
commit 94f0f7e597
5 changed files with 66 additions and 30 deletions

View File

@@ -272,7 +272,10 @@ func (c *Cache) getOrRemove(id string) hugio.ReadSeekCloser {
}
func (c *Cache) isExpired(modTime time.Time) bool {
return c.maxAge >= 0 && time.Now().Sub(modTime) > c.maxAge
if c.maxAge < 0 {
return false
}
return c.maxAge == 0 || time.Now().Sub(modTime) > c.maxAge
}
// For testing