diff options
Diffstat (limited to 'resources/image.go')
-rw-r--r-- | resources/image.go | 36 |
1 files changed, 8 insertions, 28 deletions
diff --git a/resources/image.go b/resources/image.go index fc9d2467b..4595866d4 100644 --- a/resources/image.go +++ b/resources/image.go @@ -490,36 +490,16 @@ func (i *imageResource) relTargetPathFromConfig(conf images.ImageConfig) interna if conf.TargetFormat != i.Format { p2 = conf.TargetFormat.DefaultExtension() } - - h := i.hash() - idStr := fmt.Sprintf("_hu%d_%d", h, i.size()) - - // Do not change for no good reason. - const md5Threshold = 100 - - key := conf.GetKey(i.Format) - - // It is useful to have the key in clear text, but when nesting transforms, it - // can easily be too long to read, and maybe even too long - // for the different OSes to handle. - if len(p1)+len(idStr)+len(p2) > md5Threshold { - key = hashing.MD5FromStringHexEncoded(p1 + key + p2) - huIdx := strings.Index(p1, "_hu") - if huIdx != -1 { - p1 = p1[:huIdx] - } else { - // This started out as a very long file name. Making it even longer - // could melt ice in the Arctic. - p1 = "" - } - } else if strings.Contains(p1, idStr) { - // On scaling an already scaled image, we get the file info from the original. - // Repeating the same info in the filename makes it stuttery for no good reason. - idStr = "" + const prefix = "_hu" + huIdx := strings.LastIndex(p1, prefix) + incomingID := "i" + if huIdx > -1 { + incomingID = p1[huIdx+len(prefix):] + p1 = p1[:huIdx] } - + hash := hashing.HashUint64(incomingID, i.hash(), conf.GetKey(i.Format)) rp := i.getResourcePaths() - rp.File = fmt.Sprintf("%s%s_%s%s", p1, idStr, key, p2) + rp.File = fmt.Sprintf("%s%s%d%s", p1, prefix, hash, p2) return rp } |