Skip to content

Commit

Permalink
asset: log fetches, and recognise failures
Browse files Browse the repository at this point in the history
This change makes it easier to see when the remote asset API's fetch
service is being used.

It also adds some missing error checking- the standard library http
client can fail and return a failure code, without returning an error
type.
  • Loading branch information
mostynb committed Jul 15, 2020
1 parent a68e2d9 commit 79be5fa
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions server/grpc_asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ func (s *grpcServer) fetchItem(uri string, expectedHash string) (bool, string, i
defer resp.Body.Close()
rc := resp.Body

s.accessLogger.Printf("GRPC ASSET FETCH %s %s", uri, resp.Status)
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
return false, "", int64(-1)
}

expectedSize := resp.ContentLength
if expectedHash == "" || expectedSize < 0 {
// We can't call Put until we know the hash and size.
Expand Down

0 comments on commit 79be5fa

Please sign in to comment.