Skip to content

Commit

Permalink
fix asset not ending request upon ok (#2287)
Browse files Browse the repository at this point in the history
  • Loading branch information
srliao authored Dec 5, 2024
1 parent aa5b581 commit 7131286
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/services/assets/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func (s *Server) handleGetData(t AssetType) http.HandlerFunc {
switch {
case data != nil && err == nil:
// load successful
s.logger.Info("loaded from cache ok", "t", t.String(), "key", key)
w.WriteHeader(http.StatusOK)
w.Write(data)
return
Expand All @@ -57,10 +58,12 @@ func (s *Server) handleGetData(t AssetType) http.HandlerFunc {
s.logger.Info("error getting", "err", err, "host", v.String(), "try", i, "key", key, "full_path", joinedURL.String())
continue
}
s.logger.Info("received image from source ok", "host", v.String())
s.saveToCache(t, key, data)
// found ok, save to cache and end request
w.WriteHeader(http.StatusOK)
w.Write(data)
return
}
}
// if we reached here then all external failed so we should serve default question mark image
Expand Down

0 comments on commit 7131286

Please sign in to comment.