From b8e25ea23a57f232c6601590b498d0b63f7ec175 Mon Sep 17 00:00:00 2001 From: 3AceShowHand Date: Thu, 9 Nov 2023 11:11:28 +0800 Subject: [PATCH] fix br local uri. --- 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 bc09c1d47f6de..0b2ebc7607e4e 100644 --- a/br/pkg/storage/local.go +++ b/br/pkg/storage/local.go @@ -140,7 +140,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 2e003148f5a09..fd6f92afb5b6a 100644 --- a/br/pkg/storage/local_test.go +++ b/br/pkg/storage/local_test.go @@ -157,6 +157,20 @@ func TestWalkDirSkipSubDir(t *testing.T) { })) } +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) +} + func TestLocalFileReadRange(t *testing.T) { ctx := context.Background() dir := t.TempDir()