From 535f5f3c9996fcfb53e992ea3f5217809517f470 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Tue, 13 Aug 2019 11:51:16 +0100 Subject: [PATCH] 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. --- cmd/rc/rc.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cmd/rc/rc.go b/cmd/rc/rc.go index c776e7984..6f5e13acc 100644 --- a/cmd/rc/rc.go +++ b/cmd/rc/rc.go @@ -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