rc: factor async/sync job handing into rc/jobs from rc/rcserver

This fixes async jobs with `rclone rc --loopback` which isn't very
important but sets the stage for _config setting.
This commit is contained in:
Nick Craig-Wood
2020-12-12 15:35:30 +00:00
parent a0fc10e41a
commit 8574a7bd67
4 changed files with 105 additions and 75 deletions

View File

@@ -16,6 +16,7 @@ import (
"github.com/rclone/rclone/fs/config/flags"
"github.com/rclone/rclone/fs/fshttp"
"github.com/rclone/rclone/fs/rc"
"github.com/rclone/rclone/fs/rc/jobs"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
@@ -164,7 +165,7 @@ func doCall(ctx context.Context, path string, in rc.Params) (out rc.Params, err
if call == nil {
return nil, errors.Errorf("method %q not found", path)
}
out, err = call.Fn(context.Background(), in)
_, out, err := jobs.NewJob(ctx, call.Fn, in)
if err != nil {
return nil, errors.Wrap(err, "loopback call failed")
}