summaryrefslogtreecommitdiffstats
path: root/resource/image_cache.go
diff options
context:
space:
mode:
Diffstat (limited to 'resource/image_cache.go')
-rw-r--r--resource/image_cache.go19
1 files changed, 10 insertions, 9 deletions
diff --git a/resource/image_cache.go b/resource/image_cache.go
index e63989f24..5985797d6 100644
--- a/resource/image_cache.go
+++ b/resource/image_cache.go
@@ -24,10 +24,9 @@ import (
)
type imageCache struct {
- absPublishDir string
- absCacheDir string
- pathSpec *helpers.PathSpec
- mu sync.RWMutex
+ cacheDir string
+ pathSpec *helpers.PathSpec
+ mu sync.RWMutex
store map[string]*Image
}
@@ -82,14 +81,14 @@ func (c *imageCache) getOrCreate(
parent.createMu.Lock()
defer parent.createMu.Unlock()
- cacheFilename := filepath.Join(c.absCacheDir, key)
+ cacheFilename := filepath.Join(c.cacheDir, key)
// The definition of this counter is not that we have processed that amount
// (e.g. resized etc.), it can be fetched from file cache,
// but the count of processed image variations for this site.
c.pathSpec.ProcessingStats.Incr(&c.pathSpec.ProcessingStats.ProcessedImages)
- exists, err := helpers.Exists(cacheFilename, c.pathSpec.Fs.Source)
+ exists, err := helpers.Exists(cacheFilename, c.pathSpec.BaseFs.ResourcesFs)
if err != nil {
return nil, err
}
@@ -97,7 +96,9 @@ func (c *imageCache) getOrCreate(
if exists {
img = parent.clone()
img.relTargetPath.file = relTarget.file
- img.absSourceFilename = cacheFilename
+ img.sourceFilename = cacheFilename
+ // We have to look resources file system for this.
+ img.overriddenSourceFs = img.spec.BaseFs.ResourcesFs
} else {
img, err = create(cacheFilename)
if err != nil {
@@ -124,8 +125,8 @@ func (c *imageCache) getOrCreate(
}
-func newImageCache(ps *helpers.PathSpec, absCacheDir, absPublishDir string) *imageCache {
- return &imageCache{pathSpec: ps, store: make(map[string]*Image), absCacheDir: absCacheDir, absPublishDir: absPublishDir}
+func newImageCache(ps *helpers.PathSpec, cacheDir string) *imageCache {
+ return &imageCache{pathSpec: ps, store: make(map[string]*Image), cacheDir: cacheDir}
}
func timeTrack(start time.Time, name string) {