1
0
mirror of https://github.com/rclone/rclone.git synced 2026-01-06 02:23:24 +00:00

accounting: add context.Context #3257 #4685

This commit is contained in:
Nick Craig-Wood
2020-11-05 16:59:59 +00:00
parent e3fe31f7cb
commit 1fb6ad700f
29 changed files with 138 additions and 109 deletions

View File

@@ -225,7 +225,7 @@ const (
func (d *Directory) Serve(w http.ResponseWriter, r *http.Request) {
// Account the transfer
tr := accounting.Stats(r.Context()).NewTransferRemoteSize(d.DirRemote, -1)
defer tr.Done(nil)
defer tr.Done(r.Context(), nil)
fs.Infof(d.DirRemote, "%s: Serving directory", r.RemoteAddr)

View File

@@ -77,7 +77,7 @@ func Object(w http.ResponseWriter, r *http.Request, o fs.Object) {
}
tr := accounting.Stats(r.Context()).NewTransfer(o)
defer func() {
tr.Done(err)
tr.Done(r.Context(), err)
}()
in := tr.Account(r.Context(), file) // account the transfer (no buffering)