fs: preserve explicitly supplied backend overview

This commit is contained in:
NytePlus authored and Nick Craig-Wood committed 2026-09-19 10:20:49 +01:00
1 parent 4928459f46
commit 1b3136702b
2 files changed
+32 -6

No files matched your search

+8 -6
View File
@@ -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
+24
View File
@@ -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)
})
}