Skip to content

Commit 33be8f2

Browse files
erinpentecostErin Pentecost
andauthored
Don't throw an error on a missing folder in localfs (#95)
Co-authored-by: Erin Pentecost <erin.pentecost@lytics.com>
1 parent 1c8a12f commit 33be8f2

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

localfs/store.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ func (l *LocalStore) Objects(ctx context.Context, csq cloudstorage.Query) (cloud
197197
func (l *LocalStore) Folders(ctx context.Context, csq cloudstorage.Query) ([]string, error) {
198198
spath := path.Join(l.storepath, csq.Prefix)
199199
if !cloudstorage.Exists(spath) {
200-
return nil, fmt.Errorf("That folder %q does not exist", spath)
200+
return []string{}, nil
201201
}
202202
select {
203203
case <-ctx.Done():

testutils/testutils.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,16 @@ func ListObjsAndFolders(t TestingT, store cloudstorage.Store) {
643643
folders, err = store.Folders(ctx, q)
644644
assert.NotEqual(t, nil, err)
645645
assert.Equal(t, 0, len(folders), "incorrect list len. wanted 0 folders. %v", folders)
646+
647+
// List objects from a missing folder
648+
q = cloudstorage.NewQuery("does-not-exist/")
649+
resp, err := store.List(context.Background(), q)
650+
assert.NoError(t, err)
651+
assert.NotNil(t, resp)
652+
assert.Empty(t, resp.Objects)
653+
folders, err = store.Folders(context.Background(), q)
654+
assert.NoError(t, err)
655+
assert.Empty(t, folders)
646656
}
647657

648658
func Truncate(t TestingT, store cloudstorage.Store) {

0 commit comments

Comments
 (0)