parent
1bd9288c5f
commit
6072b05d3b
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue