mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-29 10:52:06 -05:00
tpl: Use hash for cache key
Use a hash for the cache key, to fix 'file name too long' errors when retreiving from long urls Fixes #3690
This commit is contained in:
parent
dbe63970e0
commit
6cd33f6953
1 changed files with 4 additions and 2 deletions
|
@ -14,8 +14,9 @@
|
||||||
package data
|
package data
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/md5"
|
||||||
|
"encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
"net/url"
|
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/gohugoio/hugo/config"
|
"github.com/gohugoio/hugo/config"
|
||||||
|
@ -27,7 +28,8 @@ var cacheMu sync.RWMutex
|
||||||
|
|
||||||
// getCacheFileID returns the cache ID for a string.
|
// getCacheFileID returns the cache ID for a string.
|
||||||
func getCacheFileID(cfg config.Provider, id string) string {
|
func getCacheFileID(cfg config.Provider, id string) string {
|
||||||
return cfg.GetString("cacheDir") + url.QueryEscape(id)
|
hash := md5.Sum([]byte(id))
|
||||||
|
return cfg.GetString("cacheDir") + hex.EncodeToString(hash[:])
|
||||||
}
|
}
|
||||||
|
|
||||||
// getCache returns the content for an ID from the file cache or an error.
|
// getCache returns the content for an ID from the file cache or an error.
|
||||||
|
|
Loading…
Reference in a new issue