"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
fs: preserve explicitly supplied backend overview
NytePlus1b3136702b22
diff --git a/fs/registry.go b/fs/registry.goindex 6d50acaf4..4a8aa9147 100644--- a/fs/registry.go+++ b/fs/registry.go@@ -54,7 +54,7 @@ type RegInfo struct {Hide bool// MetadataInfo help about the metadata in use in this backendMetadataInfo *MetadataInfo- // Overview about the backend+ // Overview about the backend; nil loads the embedded backend metadataOverview *overview.BackendConfig}@@ -434,11 +434,13 @@ func Register(info *RegInfo) {}info.Options = append(info.Options, optDescription)Registry = append(Registry, info)- var err error- info.Overview, err = overview.GetBackendConfig(strings.ReplaceAll(info.Name, " ", ""))- if err != nil {- Errorf(nil, "internal error: no overview data found for %q", info.Name)- info.Overview = new(overview.BackendConfig)+ if info.Overview == nil {+ var err error+ info.Overview, err = overview.GetBackendConfig(strings.ReplaceAll(info.Name, " ", ""))+ if err != nil {+ Errorf(nil, "internal error: no overview data found for %q", info.Name)+ info.Overview = new(overview.BackendConfig)+ }}for _, alias := range info.Aliases {// Copy the info block and rename and hide the alias and optionsdiff --git a/fs/registry_test.go b/fs/registry_test.goindex 6f62485c2..83f3707d5 100644--- a/fs/registry_test.go+++ b/fs/registry_test.go@@ -6,6 +6,7 @@ import ("os""testing"+ "github.com/rclone/rclone/backend/overview""github.com/rclone/rclone/fs/config/configmap""github.com/spf13/pflag""github.com/stretchr/testify/assert"@@ -331,3 +332,26 @@ func TestOptionsNonDefaultRCMissingKey(t *testing.T) {_, err := opts.NonDefaultRC(c)assert.ErrorContains(t, err, "not found")}++func TestRegisterOverview(t *testing.T) {+ original := Registry+ t.Cleanup(func() { Registry = original })++ t.Run("explicit overview", func(t *testing.T) {+ supplied := &overview.BackendConfig{Backend: "external-test", Name: "External test", IntegrationTests: "not run"}+ info := &RegInfo{Name: "external-test", Overview: supplied, Aliases: []string{"external-alias"}}+ Register(info)+ require.Same(t, supplied, info.Overview)+ alias, err := Find("external-alias")+ require.NoError(t, err)+ require.Same(t, supplied, alias.Overview)+ })++ t.Run("embedded overview", func(t *testing.T) {+ info := &RegInfo{Name: "local"}+ Register(info)+ expected, err := overview.GetBackendConfig("local")+ require.NoError(t, err)+ require.Equal(t, expected, info.Overview)+ })+}