mirror of
https://github.com/foomo/contentserver.git
synced 2025-10-16 12:25:44 +00:00
fix: serve previously cached data if repo.Update fails
This commit is contained in:
parent
8b0ee0f7e0
commit
86ec47a29a
@ -76,10 +76,8 @@ func (h *HTTP) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
route := Route(strings.TrimPrefix(r.URL.Path, h.basePath+"/"))
|
route := Route(strings.TrimPrefix(r.URL.Path, h.basePath+"/"))
|
||||||
if route == RouteGetRepo {
|
if route == RouteGetRepo {
|
||||||
resp := h.repo.Update()
|
resp := h.repo.Update()
|
||||||
if resp.Success {
|
if !resp.Success {
|
||||||
h.repo.WriteRepoBytes(w)
|
h.l.Warn("repo update failed — serving previously cached data", zap.String("reason", resp.ErrorMessage))
|
||||||
} else {
|
|
||||||
http.Error(w, "failed to update repo: "+resp.ErrorMessage, http.StatusInternalServerError)
|
|
||||||
}
|
}
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
return
|
return
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user