rc: fix --loopback with rc/list and others

Before this change `rclone rc --loopback` would give the error "bad
JSON".

This was because the output of the `rc/list` command was not serialzed
through JSON.

This serializes it through JSON and fixes that (and probably other)
command.
This commit is contained in:
Nick Craig-Wood 2019-08-13 11:51:16 +01:00
parent 7f7946564d
commit 535f5f3c99

View File

@ -117,7 +117,16 @@ func doCall(path string, in rc.Params) (out rc.Params, err error) {
if call == nil {
return nil, errors.Errorf("method %q not found", path)
}
return call.Fn(context.Background(), in)
out, err = call.Fn(context.Background(), in)
if err != nil {
return nil, errors.Wrap(err, "loopback call failed")
}
// Reshape (serialize then deserialize) the data so it is in the form expected
err = rc.Reshape(&out, out)
if err != nil {
return nil, errors.Wrap(err, "loopback reshape failed")
}
return out, nil
}
// Do HTTP request