X Tutup
Skip to content

Commit 1d435a3

Browse files
committed
Ensure that cache file is closed after reading
1 parent 93c8fc1 commit 1d435a3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

api/cache.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,13 @@ func readCache(ttl time.Duration, cacheFile string, req *http.Request) (*http.Re
8484
}
8585

8686
res, err := http.ReadResponse(bufio.NewReader(f), req)
87-
if res != nil {
87+
if res == nil {
8888
res.Body = &readCloser{
8989
Reader: res.Body,
9090
Closer: f,
9191
}
92+
} else {
93+
f.Close()
9294
}
9395
return res, err
9496
}

0 commit comments

Comments
 (0)
X Tutup