"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
rc: added command core/quit
Saksham Khanna0c265713fdc9
diff --git a/fs/rc/internal.go b/fs/rc/internal.goindex 26a86c008..31dc89ed8 100644--- a/fs/rc/internal.go+++ b/fs/rc/internal.go@@ -6,11 +6,14 @@ import ("context""os""runtime"+ "time""github.com/pkg/errors"+"github.com/rclone/rclone/fs""github.com/rclone/rclone/fs/config/obscure""github.com/rclone/rclone/fs/version"+ "github.com/rclone/rclone/lib/atexit")func init() {@@ -224,3 +227,36 @@ func rcObscure(ctx context.Context, in Params) (out Params, err error) {}return out, nil}++func init() {+ Add(Call{+ Path: "core/quit",+ Fn: rcQuit,+ Title: "Terminates the app.",+ Help: `+(optional) Pass an exit code to be used for terminating the app:+- exitCode - int+`,+ })+}++// Terminates app+func rcQuit(ctx context.Context, in Params) (out Params, err error) {+ code, err := in.GetInt64("exitCode")++ if IsErrParamInvalid(err) {+ return nil, err+ }+ if IsErrParamNotFound(err) {+ code = 0+ }+ exitCode := int(code)++ go func(exitCode int) {+ time.Sleep(time.Millisecond * 1500)+ atexit.Run()+ os.Exit(exitCode)+ }(exitCode)++ return nil, nil+}diff --git a/fs/rc/internal_test.go b/fs/rc/internal_test.goindex 7abda3ff7..118215301 100644--- a/fs/rc/internal_test.go+++ b/fs/rc/internal_test.go@@ -5,11 +5,12 @@ import ("runtime""testing"+ "github.com/stretchr/testify/assert"+ "github.com/stretchr/testify/require"+"github.com/rclone/rclone/fs""github.com/rclone/rclone/fs/config/obscure""github.com/rclone/rclone/fs/version"- "github.com/stretchr/testify/assert"- "github.com/stretchr/testify/require")func TestInternalNoop(t *testing.T) {@@ -107,3 +108,14 @@ func TestCoreObscure(t *testing.T) {require.NotNil(t, out)assert.Equal(t, in["clear"], obscure.MustReveal(out["obscured"].(string)))}++func TestCoreQuit(t *testing.T) {+ //The call should return an error if param exitCode is not parsed to int+ call := Calls.Get("core/quit")+ assert.NotNil(t, call)+ in := Params{+ "exitCode": "potato",+ }+ _, err := call.Fn(context.Background(), in)+ require.Error(t, err)+}