summaryrefslogtreecommitdiffstats
path: root/cache/filecache/filecache.go
diff options
context:
space:
mode:
Diffstat (limited to 'cache/filecache/filecache.go')
-rw-r--r--cache/filecache/filecache.go28
1 files changed, 7 insertions, 21 deletions
diff --git a/cache/filecache/filecache.go b/cache/filecache/filecache.go
index 88a466218..05d9379b4 100644
--- a/cache/filecache/filecache.go
+++ b/cache/filecache/filecache.go
@@ -35,7 +35,7 @@ import (
var ErrFatal = errors.New("fatal filecache error")
const (
- filecacheRootDirname = "filecache"
+ FilecacheRootDirname = "filecache"
)
// Cache caches a set of files in a directory. This is usually a file on
@@ -301,7 +301,7 @@ func (c *Cache) isExpired(modTime time.Time) bool {
}
// For testing
-func (c *Cache) getString(id string) string {
+func (c *Cache) GetString(id string) string {
id = cleanID(id)
c.nlocker.Lock(id)
@@ -328,38 +328,24 @@ func (f Caches) Get(name string) *Cache {
// NewCaches creates a new set of file caches from the given
// configuration.
func NewCaches(p *helpers.PathSpec) (Caches, error) {
- var dcfg Configs
- if c, ok := p.Cfg.Get("filecacheConfigs").(Configs); ok {
- dcfg = c
- } else {
- var err error
- dcfg, err = DecodeConfig(p.Fs.Source, p.Cfg)
- if err != nil {
- return nil, err
- }
- }
-
+ dcfg := p.Cfg.GetConfigSection("caches").(Configs)
fs := p.Fs.Source
m := make(Caches)
for k, v := range dcfg {
var cfs afero.Fs
- if v.isResourceDir {
+ if v.IsResourceDir {
cfs = p.BaseFs.ResourcesCache
} else {
cfs = fs
}
if cfs == nil {
- // TODO(bep) we still have some places that do not initialize the
- // full dependencies of a site, e.g. the import Jekyll command.
- // That command does not need these caches, so let us just continue
- // for now.
- continue
+ panic("nil fs")
}
- baseDir := v.Dir
+ baseDir := v.DirCompiled
if err := cfs.MkdirAll(baseDir, 0777); err != nil && !os.IsExist(err) {
return nil, err
@@ -368,7 +354,7 @@ func NewCaches(p *helpers.PathSpec) (Caches, error) {
bfs := afero.NewBasePathFs(cfs, baseDir)
var pruneAllRootDir string
- if k == cacheKeyModules {
+ if k == CacheKeyModules {
pruneAllRootDir = "pkg"
}