rc: fix stats groups being ignored in operations/check

Before this change operations/check was using a background context for
the checking which was causing the stats group to be ignored.

This fixes the problem and also a similar problem in backend/command

See: https://forum.rclone.org/t/operations-check-only-reports-to-global-stats-not-per-job-group/45254
This commit is contained in:
Nick Craig-Wood 2024-03-25 17:56:33 +00:00
parent efed6b01d2
commit 215ae17272

View File

@ -639,7 +639,7 @@ func rcBackend(ctx context.Context, in rc.Params) (out rc.Params, err error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
result, err := doCommand(context.Background(), command, arg, opt) result, err := doCommand(ctx, command, arg, opt)
if err != nil { if err != nil {
return nil, fmt.Errorf("command %q failed: %w", command, err) return nil, fmt.Errorf("command %q failed: %w", command, err)
@ -858,13 +858,13 @@ func rcCheck(ctx context.Context, in rc.Params) (out rc.Params, err error) {
if checkFileHash != "" { if checkFileHash != "" {
out["hashType"] = checkFileHashType.String() out["hashType"] = checkFileHashType.String()
err = CheckSum(context.Background(), dstFs, checkFileFs, checkFileRemote, checkFileHashType, opt, download) err = CheckSum(ctx, dstFs, checkFileFs, checkFileRemote, checkFileHashType, opt, download)
} else { } else {
if download { if download {
err = CheckDownload(context.Background(), opt) err = CheckDownload(ctx, opt)
} else { } else {
out["hashType"] = srcFs.Hashes().Overlap(dstFs.Hashes()).GetOne().String() out["hashType"] = srcFs.Hashes().Overlap(dstFs.Hashes()).GetOne().String()
err = Check(context.Background(), opt) err = Check(ctx, opt)
} }
} }
if err != nil { if err != nil {