From: Jake Howard Date: Fri, 21 Jul 2017 11:10:11 +0000 (+0100) Subject: tpl: Use hash for cache key X-Git-Tag: v0.26~30 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=6cd33f695;p=brevno-suite%2Fhugo 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 --- diff --git a/tpl/data/cache.go b/tpl/data/cache.go index b4f91c0f..6c403316 100644 --- a/tpl/data/cache.go +++ b/tpl/data/cache.go @@ -14,8 +14,9 @@ package data import ( + "crypto/md5" + "encoding/hex" "errors" - "net/url" "sync" "github.com/gohugoio/hugo/config" @@ -27,7 +28,8 @@ var cacheMu sync.RWMutex // getCacheFileID returns the cache ID for a 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.