mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-29 22:29:56 +02:00
tpl: Do not write to cache when ignoring cache
Fixes #2067 Closes #2069
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
5d50c46482
commit
24cb0d1f58
@@ -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
|
||||
}
|
||||
|
@@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user