From 97c0f49c43e8977766e76542e090629350441311 Mon Sep 17 00:00:00 2001 From: Ti Chi Robot Date: Fri, 24 Nov 2023 20:50:44 +0800 Subject: [PATCH] br: fix incorrect uri for the file storage (#48453) (#48721) close pingcap/tidb#48452 --- br/pkg/storage/local.go | 2 +- br/pkg/storage/local_test.go | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/br/pkg/storage/local.go b/br/pkg/storage/local.go index c0285812dc720..3d3712db33fcb 100644 --- a/br/pkg/storage/local.go +++ b/br/pkg/storage/local.go @@ -121,7 +121,7 @@ func (l *LocalStorage) WalkDir(_ context.Context, opt *WalkOption, fn func(strin // URI returns the base path as an URI with a file:/// prefix. func (l *LocalStorage) URI() string { - return LocalURIPrefix + "/" + l.base + return LocalURIPrefix + l.base } // Open a Reader by file path, path is a relative path to base path. diff --git a/br/pkg/storage/local_test.go b/br/pkg/storage/local_test.go index 21ac630c865f1..917dd94bd9a41 100644 --- a/br/pkg/storage/local_test.go +++ b/br/pkg/storage/local_test.go @@ -127,3 +127,17 @@ func TestWalkDirWithSoftLinkFile(t *testing.T) { }) require.NoError(t, err) } + +func TestLocalURI(t *testing.T) { + ctx := context.Background() + + url := "file:///tmp/folder" + sb, err := ParseBackend(url, &BackendOptions{}) + require.NoError(t, err) + + store, err := Create(ctx, sb, true) + require.NoError(t, err) + + obtained := store.URI() + require.Equal(t, url, obtained) +}