Skip to content
This repository was archived by the owner on Jan 31, 2024. It is now read-only.

Commit 73a716d

Browse files
committed
search: fix search behavior, return match list
1 parent d1f2530 commit 73a716d

File tree

2 files changed

+20
-21
lines changed

2 files changed

+20
-21
lines changed

pkg/eosclient/eosbinary/eosbinary.go

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -735,19 +735,8 @@ func (c *Client) SearchDir(ctx context.Context, auth eosclient.Authorization, se
735735
return nil, errors.Errorf("eosclient: ilegal search string: %s", searchString)
736736
}
737737
// TODO: set a timeout for the find in case it goes out of hand
738-
stdout, stderr, err := c.executeEOS(ctx, args, auth)
739-
if err != nil {
740-
// Errcode 7: "TOOBIG"
741-
if stdout != "" {
742-
log.Debug().Msgf("eos find stdout= %s", stdout)
743-
log.Debug().Msgf("=========== eos find stderr =========== %s", stderr)
744-
return c.parseFind(ctx, auth, path, stdout)
745-
} else {
746-
log.Debug().Msgf("eosbinary - user had insufficient permissions to search part of the directory")
747-
// There will be errors; we cannot ignore them:
748-
return nil, errors.Wrapf(err, "eosclient: error listing fn=%s", path)
749-
}
750-
}
738+
stdout, _, _ := c.executeEOS(ctx, args, auth)
739+
// We can ignore errors and stderr, we're just interested on the EOS output
751740
log.Debug().Msgf("eos find stdout= %s", stdout)
752741
return c.parseFind(ctx, auth, path, stdout)
753742
}

pkg/storage/utils/eosfs/eosfs.go

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,25 +1336,29 @@ func (fs *eosfs) ListFolder(ctx context.Context, ref *provider.Reference, mdKeys
13361336
// - also check that searchString not empty:
13371337
searchString = mdKeys[i+1]
13381338

1339+
if searchString == "" {
1340+
return nil, errtypes.NotSupported("Search requires a search string")
1341+
}
1342+
13391343
log.Debug().Msgf("eosfs: running search: path=%s searchString=%s", p, searchString)
13401344

13411345
eosFileInfos, err := fs.c.SearchDir(ctx, auth, searchString, p)
1346+
13421347
if err != nil {
13431348
return nil, errors.Wrap(err, "eosfs: error searching")
13441349
}
13451350

13461351
for _, eosFileInfo := range eosFileInfos {
1347-
// filter out sys files
1348-
if !fs.conf.ShowHiddenSysFiles {
1349-
base := path.Base(eosFileInfo.File)
1350-
if hiddenReg.MatchString(base) {
1351-
continue
1352-
}
1353-
}
13541352

1355-
if finfo, err := fs.convertToFileReference(ctx, eosFileInfo); err == nil {
1353+
log.Debug().Msgf("seach: eosFileInfo %s", eosFileInfo.File)
1354+
1355+
// Search all files, hidden and not, for the time being
1356+
1357+
if finfo, err := fs.convertToResourceInfo(ctx, eosFileInfo); err == nil {
13561358
log.Debug().Msgf("eosfs: file name from search %s", finfo.Name)
13571359
finfos = append(finfos, finfo)
1360+
} else {
1361+
log.Error().Err(err).Msg(" wtf 🥘")
13581362
}
13591363
}
13601364

@@ -2120,6 +2124,8 @@ func (fs *eosfs) convertToResourceInfo(ctx context.Context, eosFileInfo *eosclie
21202124
}
21212125

21222126
func (fs *eosfs) convertToFileReference(ctx context.Context, eosFileInfo *eosclient.FileInfo) (*provider.ResourceInfo, error) {
2127+
log := appctx.GetLogger(ctx)
2128+
log.Debug().Msg("convertToFileReference")
21232129
info, err := fs.convert(ctx, eosFileInfo)
21242130
if err != nil {
21252131
return nil, err
@@ -2258,6 +2264,8 @@ func mergePermissions(l *provider.ResourcePermissions, r *provider.ResourcePermi
22582264
}
22592265

22602266
func (fs *eosfs) convert(ctx context.Context, eosFileInfo *eosclient.FileInfo) (*provider.ResourceInfo, error) {
2267+
log := appctx.GetLogger(ctx)
2268+
log.Debug().Msg("convert")
22612269
path, err := fs.unwrap(ctx, eosFileInfo.File)
22622270
if err != nil {
22632271
return nil, err
@@ -2293,6 +2301,8 @@ func (fs *eosfs) convert(ctx context.Context, eosFileInfo *eosclient.FileInfo) (
22932301
}
22942302
}
22952303

2304+
log.Debug().Msgf("convert: marshalling the eosFileInfo %s", eosFileInfo)
2305+
22962306
info := &provider.ResourceInfo{
22972307
Id: &provider.ResourceId{OpaqueId: fmt.Sprintf("%d", eosFileInfo.Inode)},
22982308
Path: path,

0 commit comments

Comments
 (0)