From 33be8f2dec011675a3a6d3092ac1625e82902f3d Mon Sep 17 00:00:00 2001 From: Erin Pentecost <7728019+erinpentecost@users.noreply.github.com> Date: Tue, 20 Jul 2021 15:11:49 -0700 Subject: [PATCH] Don't throw an error on a missing folder in localfs (#95) Co-authored-by: Erin Pentecost --- localfs/store.go | 2 +- testutils/testutils.go | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/localfs/store.go b/localfs/store.go index e76c557..d0daf06 100644 --- a/localfs/store.go +++ b/localfs/store.go @@ -197,7 +197,7 @@ func (l *LocalStore) Objects(ctx context.Context, csq cloudstorage.Query) (cloud func (l *LocalStore) Folders(ctx context.Context, csq cloudstorage.Query) ([]string, error) { spath := path.Join(l.storepath, csq.Prefix) if !cloudstorage.Exists(spath) { - return nil, fmt.Errorf("That folder %q does not exist", spath) + return []string{}, nil } select { case <-ctx.Done(): diff --git a/testutils/testutils.go b/testutils/testutils.go index e29f44a..4a7492e 100644 --- a/testutils/testutils.go +++ b/testutils/testutils.go @@ -643,6 +643,16 @@ func ListObjsAndFolders(t TestingT, store cloudstorage.Store) { folders, err = store.Folders(ctx, q) assert.NotEqual(t, nil, err) assert.Equal(t, 0, len(folders), "incorrect list len. wanted 0 folders. %v", folders) + + // List objects from a missing folder + q = cloudstorage.NewQuery("does-not-exist/") + resp, err := store.List(context.Background(), q) + assert.NoError(t, err) + assert.NotNil(t, resp) + assert.Empty(t, resp.Objects) + folders, err = store.Folders(context.Background(), q) + assert.NoError(t, err) + assert.Empty(t, folders) } func Truncate(t TestingT, store cloudstorage.Store) {