Fixed issue where zips wouldn't be closed after trying to read comicinfo.xml.
This commit is contained in:
+12
-11
@@ -71,18 +71,19 @@ func Index(w http.ResponseWriter, r *http.Request) {
|
|||||||
zf, err := zip.OpenReader(path)
|
zf, err := zip.OpenReader(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
} else {
|
}
|
||||||
for i := range zf.File {
|
|
||||||
if strings.ToLower(zf.File[i].Name) == "comicinfo.xml" {
|
defer zf.Close()
|
||||||
cif, err := zf.File[i].Open()
|
for i := range zf.File {
|
||||||
if err != nil {
|
if strings.ToLower(zf.File[i].Name) == "comicinfo.xml" {
|
||||||
return err
|
cif, err := zf.File[i].Open()
|
||||||
}
|
if err != nil {
|
||||||
cib, _ := io.ReadAll(cif)
|
return nil
|
||||||
_ = cif.Close()
|
|
||||||
_ = xml.Unmarshal(cib, &ComicInfo)
|
|
||||||
c.Set(path, ComicInfo, cache.NoExpiration)
|
|
||||||
}
|
}
|
||||||
|
cib, _ := io.ReadAll(cif)
|
||||||
|
_ = cif.Close()
|
||||||
|
_ = xml.Unmarshal(cib, &ComicInfo)
|
||||||
|
c.Set(path, ComicInfo, cache.NoExpiration)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user