Skip to content

Commit

Permalink
Fix network issue and use cache when network is down (#109)
Browse files Browse the repository at this point in the history
Relate to #108

I think it's not only an issue with http_proxy. I can reproduce this error without http_proxy settings by plug/unplug my network cable (forcing a connection issue during pacoloco's network activity), same problem will show up.

After a little tinkering I think the problem is d is not ended by default. And I added f.cachedFileExists so that cache can be served. (Otherwise pacoloco would just return err without sending anything. https://github.com/anatol/pacoloco/blob/master/pacoloco.go#L270)

This has a little bit downside, it would not register a cacheServingFailedCounter if cache is sent. But I guess that would not be a fail after all?
  • Loading branch information
ykelvis authored May 29, 2024
1 parent f255912 commit bb774b2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,12 @@ func getDownloadReader(f *RequestedFile) (time.Time, io.ReadSeekCloser, error) {
}

// we are done downloading without correctly received metadata, it is an error
// end 'd' properly
d.decrementUsage()
// if cache exists, use that
if f.cachedFileExists() {
return time.Time{}, nil, nil
}
return time.Time{}, nil, d.eventError
}

Expand Down

0 comments on commit bb774b2

Please sign in to comment.