Skip to content

Commit

Permalink
Don't throw an error on a missing folder in localfs (#95)
Browse files Browse the repository at this point in the history
Co-authored-by: Erin Pentecost <erin.pentecost@lytics.com>
  • Loading branch information
erinpentecost and Erin Pentecost authored Jul 20, 2021
1 parent 1c8a12f commit 33be8f2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion localfs/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
10 changes: 10 additions & 0 deletions testutils/testutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 33be8f2

Please sign in to comment.