FstatRemote stats a remote file.
()
| 77 | |
| 78 | // FstatRemote stats a remote file. |
| 79 | func (r *reader) FstatRemote() (int64, error) { |
| 80 | key := r.context.GetString(pcontext.FileChunkCtxKey) |
| 81 | start := int64(0) |
| 82 | end := int64(0) |
| 83 | |
| 84 | log := r.Log().With().Str("operation", "fstatremote").Int64("start", start).Int64("end", end).Str("key", key).Logger() |
| 85 | |
| 86 | startTime := time.Now() |
| 87 | originReq, err := r.originRequest(start, end) |
| 88 | if err != nil { |
| 89 | return -1, err |
| 90 | } |
| 91 | |
| 92 | var count int64 |
| 93 | defer func() { |
| 94 | r.metricsRecorder.RecordUpstreamResponse(originReq.URL.Hostname(), key, "fstat", time.Since(startTime).Seconds(), count) |
| 95 | }() |
| 96 | count, err = r.fstatRemote(log, originReq, r.defaultHttpClient) |
| 97 | return count, err |
| 98 | } |
| 99 | |
| 100 | // doP2p tries to resolve the key in the p2p network and if successful, it will perform the operation on the peer, and return the result. |
| 101 | func (r *reader) doP2p(log zerolog.Logger, fileChunkKey string, start, end int64, o operation, buf []byte) (int64, error) { |
nothing calls this directly
no test coverage detected