Actually handle all possible errors while attempting to read comicinfo.xml.

This commit is contained in:
2024-12-31 03:50:25 -07:00
parent d2e59a9dbd
commit 1211164b79
2 changed files with 30 additions and 6 deletions
+29 -5
View File
@@ -80,9 +80,22 @@ func Index(w http.ResponseWriter, r *http.Request) {
if err != nil {
return nil
}
cib, _ := io.ReadAll(cif)
_ = cif.Close()
_ = xml.Unmarshal(cib, &ComicInfo)
cib, err := io.ReadAll(cif)
if err != nil {
return nil
}
err = cif.Close()
if err != nil {
return nil
}
err = xml.Unmarshal(cib, &ComicInfo)
if err != nil {
return nil
}
c.Set(path, ComicInfo, cache.NoExpiration)
}
}
@@ -132,10 +145,21 @@ func Index(w http.ResponseWriter, r *http.Request) {
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
err = defaults.Set(&feed)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
data, err := xml.MarshalIndent(feed, "", " ")
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
_ = defaults.Set(&feed)
data, _ := xml.MarshalIndent(feed, "", " ")
http.ServeContent(w, r, "feed.xml", time.Now(), bytes.NewReader(data))
}
+1 -1
View File
@@ -14,7 +14,7 @@ func main() {
app := cli.NewApp()
app.Name = "go-opds-pse"
app.Usage = "A lightweight OPDS server with PSE support."
app.Version = "1.0.0+dev"
app.Version = "1.0.1+dev"
app.Flags = []cli.Flag{
cmd.StringFlag("manga, m", "manga", "default manga folder"),
}