Commit 6072b05d authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

packer: Extension works properly with URLs too

/cc @sit
parent 1bd9288c
...@@ -76,6 +76,11 @@ func (f *FileCache) cachePath(key string, hashKey string) string { ...@@ -76,6 +76,11 @@ func (f *FileCache) cachePath(key string, hashKey string) string {
dotIndex := strings.LastIndex(key, ".") dotIndex := strings.LastIndex(key, ".")
if dotIndex > -1 { if dotIndex > -1 {
suffix = key[dotIndex:len(key)] suffix = key[dotIndex:len(key)]
idx := strings.Index(suffix, "?")
if idx != -1 {
suffix = suffix[0:idx]
}
} }
return filepath.Join(f.CacheDir, hashKey+suffix) return filepath.Join(f.CacheDir, hashKey+suffix)
......
...@@ -37,8 +37,13 @@ func TestFileCache(t *testing.T) { ...@@ -37,8 +37,13 @@ func TestFileCache(t *testing.T) {
defer os.RemoveAll(cacheDir) defer os.RemoveAll(cacheDir)
cache := &FileCache{CacheDir: 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") { if !strings.HasSuffix(path, ".iso") {
t.Fatalf("path doesn't end with suffix '%s': '%s'", ".iso", path) t.Fatalf("path doesn't end with suffix '%s': '%s'", ".iso", path)
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment