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

Commit

Permalink
search: log stderr from 'eos find' and replace mock response
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuAlfageme committed Feb 8, 2023
1 parent d8a4e55 commit 8736519
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions internal/http/services/owncloud/ocdav/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (

rpcv1beta1 "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
typespb "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
types "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
"github.com/cs3org/reva/pkg/appctx"
ctxpkg "github.com/cs3org/reva/pkg/ctx"
)
Expand Down Expand Up @@ -68,7 +68,7 @@ func (s *svc) doSearchFiles(w http.ResponseWriter, r *http.Request, sf *reportSe
ctx := r.Context()
log := appctx.GetLogger(ctx)

log.Info().Msgf("hugo: search is: %+v", sf)
log.Info().Msgf("search is: %+v", sf)

client, err := s.getClient()
if err != nil {
Expand All @@ -77,7 +77,7 @@ func (s *svc) doSearchFiles(w http.ResponseWriter, r *http.Request, sf *reportSe
return
}

opaqueMap := map[string]*typespb.OpaqueEntry{
opaqueMap := map[string]*types.OpaqueEntry{
"search": {
Decoder: "plain",
Value: []byte("search"),
Expand All @@ -88,10 +88,10 @@ func (s *svc) doSearchFiles(w http.ResponseWriter, r *http.Request, sf *reportSe
},
}

// TODO(salfagem): hardcoded path for the time being:
ref := &provider.Reference{Path: "/eos/project/t/test"}
// TODO(salfagem): hardcoded path for the time being, enable a list:
ref := &provider.Reference{Path: "/eos/project/a/awesomeproject"}

req := &provider.ListContainerRequest{Opaque: &typespb.Opaque{
req := &provider.ListContainerRequest{Opaque: &types.Opaque{
Map: opaqueMap,
}, Ref: ref}

Expand Down
12 changes: 6 additions & 6 deletions pkg/eosclient/eosbinary/eosbinary.go
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ func (c *Client) SearchDir(ctx context.Context, auth eosclient.Authorization, se
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/t/test") {
if !strings.HasPrefix(path, "/eos/project/a/awesomeproject") {
log.Debug().Msgf("eosbinary - prefix doesn't match")
return nil, errors.Errorf("eosclient: search path out of bounds fn=%s", path)
}
Expand All @@ -735,18 +735,18 @@ func (c *Client) SearchDir(ctx context.Context, auth eosclient.Authorization, se
return nil, errors.Errorf("eosclient: ilegal search string: %s", searchString)
}
// TODO: set a timeout for the find in case it goes out of hand
stdout, _, err := c.executeEOS(ctx, args, auth)
stdout, stderr, err := c.executeEOS(ctx, args, auth)
if err != nil {
switch err.(type) {
case errtypes.NotFound, errtypes.PermissionDenied:
case errtypes.IsNotFound, errtypes.IsPermissionDenied:
log.Debug().Msgf("eosbinary - user had insufficient permissions to search part of the directory")
default:
log.Error().Msgf("ERRROR LISTING= %s", stdout)
// There will be errors:
//return nil, errors.Wrapf(err, "eosclient: error listing fn=%s", path)
// There will be errors; we cannot ignore them:
return nil, errors.Wrapf(err, "eosclient: error listing fn=%s", path)
}
}
log.Debug().Msgf("eos find stdout= %s", stdout)
log.Debug().Msgf("=========== eos find stderr =========== %s", stderr)
return c.parseFind(ctx, auth, path, stdout)
}

Expand Down

0 comments on commit 8736519

Please sign in to comment.