diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-01-15 20:22:14 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-01-15 20:22:14 +0100 |
commit | ecaf14514e06321823bdd10235cf23e7d654ba77 (patch) | |
tree | 5df06870d994d326fb75ed03ac43f9e61e29ab3b /resource/image.go | |
parent | d4f8f88e67f958b8010f90cb9b9854114e52dac2 (diff) |
resource: Fix handling of very long image file names
Fixes #4261
Diffstat (limited to 'resource/image.go')
-rw-r--r-- | resource/image.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/resource/image.go b/resource/image.go index 191aaf84c..e9a617f97 100644 --- a/resource/image.go +++ b/resource/image.go @@ -538,7 +538,14 @@ func (i *Image) filenameFromConfig(conf imageConfig) string { // for the different OSes to handle. if len(p1)+len(idStr)+len(p2) > md5Threshold { key = helpers.MD5String(p1 + key + p2) - p1 = p1[:strings.Index(p1, "_hu")] + 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. |