Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

fs: preserve explicitly supplied backend overview

NytePlus1b3136702b22
diff --git a/fs/registry.go b/fs/registry.go
index 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 backend
MetadataInfo *MetadataInfo
- // Overview about the backend
+ // Overview about the backend; nil loads the embedded backend metadata
Overview *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 options
diff --git a/fs/registry_test.go b/fs/registry_test.go
index 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)
+ })
+}