diff --git a/packer/cache.go b/packer/cache.go index 91fd92593..ae0c2ef6b 100644 --- a/packer/cache.go +++ b/packer/cache.go @@ -76,6 +76,11 @@ func (f *FileCache) cachePath(key string, hashKey string) string { dotIndex := strings.LastIndex(key, ".") if dotIndex > -1 { suffix = key[dotIndex:len(key)] + + idx := strings.Index(suffix, "?") + if idx != -1 { + suffix = suffix[0:idx] + } } return filepath.Join(f.CacheDir, hashKey+suffix) diff --git a/packer/cache_test.go b/packer/cache_test.go index 3d2ac70dc..2d76edee5 100644 --- a/packer/cache_test.go +++ b/packer/cache_test.go @@ -37,8 +37,13 @@ func TestFileCache(t *testing.T) { defer os.RemoveAll(cacheDir) cache := &FileCache{CacheDir: cacheDir} - path := cache.Lock("foo.iso") + path := cache.Lock("foo.ext?foo=bar") + defer cache.Unlock("foo.ext?foo=bar") + if !strings.HasSuffix(path, ".ext") { + t.Fatalf("bad extension with question mark: %s", path) + } + path = cache.Lock("foo.iso") if !strings.HasSuffix(path, ".iso") { t.Fatalf("path doesn't end with suffix '%s': '%s'", ".iso", path) }