Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tpl
diff options
context:
space:
mode:
authorRobert Basic <robertbasic.com@gmail.com>2016-04-10 13:11:18 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-04-14 11:48:26 +0300
commit24cb0d1f5801cc8b4dcbbf99ffb463e2e02c5dd3 (patch)
tree68dd80631b5ff83f05c1aa2b2e14a1480f925ed0 /tpl
parent5d50c46482d231efa26c95e4705e720fb9bf753c (diff)
tpl: Do not write to cache when ignoring cache
Fixes #2067 Closes #2069
Diffstat (limited to 'tpl')
-rw-r--r--tpl/template_resources.go7
-rw-r--r--tpl/template_resources_test.go2
2 files changed, 6 insertions, 3 deletions
diff --git a/tpl/template_resources.go b/tpl/template_resources.go
index 76a83a87f..07451734d 100644
--- a/tpl/template_resources.go
+++ b/tpl/template_resources.go
@@ -92,7 +92,10 @@ func resGetCache(id string, fs afero.Fs, ignoreCache bool) ([]byte, error) {
}
// resWriteCache writes bytes to an ID into the file cache
-func resWriteCache(id string, c []byte, fs afero.Fs) error {
+func resWriteCache(id string, c []byte, fs afero.Fs, ignoreCache bool) error {
+ if ignoreCache {
+ return nil
+ }
fID := getCacheFileID(id)
f, err := fs.Create(fID)
if err != nil {
@@ -147,7 +150,7 @@ func resGetRemote(url string, fs afero.Fs, hc *http.Client) ([]byte, error) {
if err != nil {
return nil, err
}
- err = resWriteCache(url, c, fs)
+ err = resWriteCache(url, c, fs, viper.GetBool("IgnoreCache"))
if err != nil {
return nil, err
}
diff --git a/tpl/template_resources_test.go b/tpl/template_resources_test.go
index d091595b0..909edc5d5 100644
--- a/tpl/template_resources_test.go
+++ b/tpl/template_resources_test.go
@@ -58,7 +58,7 @@ func TestScpCache(t *testing.T) {
t.Errorf("There is content where there should not be anything: %s", string(c))
}
- err = resWriteCache(test.path, test.content, fs)
+ err = resWriteCache(test.path, test.content, fs, test.ignore)
if err != nil {
t.Errorf("Error writing cache: %s", err)
}