diff --git a/internal/grpc/services/storageprovider/storageprovider.go b/internal/grpc/services/storageprovider/storageprovider.go index 34cfc791e5b..2c6253198b0 100644 --- a/internal/grpc/services/storageprovider/storageprovider.go +++ b/internal/grpc/services/storageprovider/storageprovider.go @@ -940,9 +940,9 @@ func (s *service) ListContainer(ctx context.Context, req *provider.ListContainer }, nil } - // Hack to enable search + // Ugly hack to enable search if req.Opaque.Map["search"] != nil { - s.storage.ListFolder(ctx, newRef, []string{"search"}) + s.storage.ListFolder(ctx, newRef, []string{"search", string(req.Opaque.Map["searchString"].GetValue())}) } mds, err := s.storage.ListFolder(ctx, newRef, req.ArbitraryMetadataKeys) diff --git a/internal/http/services/owncloud/ocdav/report.go b/internal/http/services/owncloud/ocdav/report.go index e1040f398e8..6adea632c04 100644 --- a/internal/http/services/owncloud/ocdav/report.go +++ b/internal/http/services/owncloud/ocdav/report.go @@ -43,6 +43,7 @@ func (s *svc) handleReport(w http.ResponseWriter, r *http.Request, ns string) { ctx := r.Context() log := appctx.GetLogger(ctx) + // TODO(salfagem): catch empty request body rep, status, err := readReport(r.Body) if err != nil { log.Error().Err(err).Msg("error reading report") @@ -62,8 +63,6 @@ func (s *svc) handleReport(w http.ResponseWriter, r *http.Request, ns string) { return } - // TODO(jfd): implement report - w.WriteHeader(http.StatusNotImplemented) } @@ -85,8 +84,13 @@ func (s *svc) doSearchFiles(w http.ResponseWriter, r *http.Request, sf *reportSe Decoder: "plain", Value: []byte("search"), }, + "searchString": { + Decoder: "plain", + Value: []byte(sf.Search.Pattern), + }, } + // TODO(salfagem): hardcoded path for the time being: ref := &provider.Reference{Path: "/eos/project/c/cernbox"} req := &provider.ListContainerRequest{Opaque: &typespb.Opaque{ diff --git a/pkg/eosclient/eosbinary/eosbinary.go b/pkg/eosclient/eosbinary/eosbinary.go index dab65316017..aacfcfcf52f 100644 --- a/pkg/eosclient/eosbinary/eosbinary.go +++ b/pkg/eosclient/eosbinary/eosbinary.go @@ -745,14 +745,19 @@ func (c *Client) List(ctx context.Context, auth eosclient.Authorization, path st // List the contents of the directory given by path with depth infinity func (c *Client) SearchDir(ctx context.Context, auth eosclient.Authorization, searchString string, path string) ([]*eosclient.FileInfo, error) { - args := []string{"find", "--fileinfo", "--name", searchString, path} + // TODO(salfagem): path is truncated - i.e. /c/cernbox (not absolute) + args := []string{"find", "--fileinfo", "-name", searchString, path} + log := appctx.GetLogger(ctx) + log.Debug().Msgf("eosbinary search with args: %s", args) // Safeguard #2 to prevent the search to go to undesired places: if !strings.HasPrefix(path, "/eos/project/c/cernbox") { + log.Debug().Msgf("eosbinary - prefix doesn't match") return nil, errors.Errorf("eosclient: search path out of bounds fn=%s", path) } // For the moment, just file names are supported, no paths (and no parentheses, braquets...) searchStringMatch, _ := regexp.MatchString(`^[\w\d\s\*\-\.]+$`, searchString) if !searchStringMatch { + log.Debug().Msgf("eosbinary - searchstring is not valid") return nil, errors.Errorf("eosclient: ilegal search string: %s", searchString) } // TODO: set a timeout for the find in case it goes out of hand diff --git a/pkg/storage/utils/eosfs/eosfs.go b/pkg/storage/utils/eosfs/eosfs.go index 6055355b4f4..d21f8dbd091 100644 --- a/pkg/storage/utils/eosfs/eosfs.go +++ b/pkg/storage/utils/eosfs/eosfs.go @@ -63,7 +63,6 @@ import ( const ( refTargetAttrKey = "reva.target" - lwShareAttrKey = "reva.lwshare" ) const ( @@ -1275,11 +1274,16 @@ func (fs *eosfs) getMDShareFolder(ctx context.Context, p string, mdKeys []string } func (fs *eosfs) ListFolder(ctx context.Context, ref *provider.Reference, mdKeys []string) ([]*provider.ResourceInfo, error) { + log := appctx.GetLogger(ctx) + p, err := fs.resolve(ctx, ref) + if err != nil { return nil, errors.Wrap(err, "eosfs: error resolving reference") } + p = fs.wrap(ctx, p) + u, err := getUser(ctx) if err != nil { return nil, errors.Wrap(err, "eosfs: no user in ctx") @@ -1295,8 +1299,11 @@ func (fs *eosfs) ListFolder(ctx context.Context, ref *provider.Reference, mdKeys for i, key := range mdKeys { if key == "search" { - // Check that searchString not empty - searchString = mdKeys[i] + // TODO(salfagem): Ugly hack due to mdKeys being an array. + // - also check that searchString not empty: + searchString = mdKeys[i+1] + + log.Info().Msgf("eosfs: running search: path=%s searchString=%s", p, searchString) eosFileInfos, err := fs.c.SearchDir(ctx, auth, searchString, p) if err != nil {