Actually handle all possible errors while attempting to read comicinfo.xml.
This commit is contained in:
+29
-5
@@ -80,9 +80,22 @@ func Index(w http.ResponseWriter, r *http.Request) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
cib, _ := io.ReadAll(cif)
|
|
||||||
_ = cif.Close()
|
cib, err := io.ReadAll(cif)
|
||||||
_ = xml.Unmarshal(cib, &ComicInfo)
|
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)
|
c.Set(path, ComicInfo, cache.NoExpiration)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -132,10 +145,21 @@ func Index(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
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))
|
http.ServeContent(w, r, "feed.xml", time.Now(), bytes.NewReader(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ func main() {
|
|||||||
app := cli.NewApp()
|
app := cli.NewApp()
|
||||||
app.Name = "go-opds-pse"
|
app.Name = "go-opds-pse"
|
||||||
app.Usage = "A lightweight OPDS server with PSE support."
|
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{
|
app.Flags = []cli.Flag{
|
||||||
cmd.StringFlag("manga, m", "manga", "default manga folder"),
|
cmd.StringFlag("manga, m", "manga", "default manga folder"),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user