From b31f37f2109ad1e30b5c810e8c8762de6c6394d4 Mon Sep 17 00:00:00 2001 From: Samuel Alfageme Sainz Date: Tue, 13 Dec 2022 13:55:16 +0100 Subject: [PATCH] eosbinary: change name parameter and sandbox project --- .../http/services/owncloud/ocdav/report.go | 84 +++++++++---------- pkg/eosclient/eosbinary/eosbinary.go | 9 +- pkg/storage/utils/eosfs/eosfs.go | 3 +- 3 files changed, 50 insertions(+), 46 deletions(-) diff --git a/internal/http/services/owncloud/ocdav/report.go b/internal/http/services/owncloud/ocdav/report.go index 7ec2123568a..01eae094c10 100644 --- a/internal/http/services/owncloud/ocdav/report.go +++ b/internal/http/services/owncloud/ocdav/report.go @@ -89,7 +89,7 @@ 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/c/cernbox"} + ref := &provider.Reference{Path: "/eos/project/t/test"} req := &provider.ListContainerRequest{Opaque: &typespb.Opaque{ Map: opaqueMap, @@ -103,52 +103,52 @@ func (s *svc) doSearchFiles(w http.ResponseWriter, r *http.Request, sf *reportSe return } + log.Debug().Msgf("search: found %d matches", len(res.Infos)) + for _, v := range res.Infos { log.Debug().Msg(v.Path) } data := ` - - - - /remote.php/dav/spaces/1284d238-aa92-42ce-bdc4-0b0000009157$4c510ada-c86b-4815-8820-42cdf82c3d51/asd.txt - - - 1284d238-aa92-42ce-bdc4-0b0000009157$4c510ada-c86b-4815-8820-42cdf82c3d51!d5613880-307c-4e3e-b56d-97839fcf6d03 - 1284d238-aa92-42ce-bdc4-0b0000009157$4c510ada-c86b-4815-8820-42cdf82c3d51!4c510ada-c86b-4815-8820-42cdf82c3d51 - asd.txt - 2022-11-08T10:45:16Z - text/plain - RDNVW - - - 0 - 0.4809828996658325 - - HTTP/1.1 200 OK - - - - /remote.php/dav/spaces/1284d238-aa92-42ce-bdc4-0b0000009157$4c510ada-c86b-4815-8820-42cdf82c3d51/asdddddd - - - 1284d238-aa92-42ce-bdc4-0b0000009157$4c510ada-c86b-4815-8820-42cdf82c3d51!fa3c7a85-5fc4-46d3-a0b1-293a282da1b7 - 1284d238-aa92-42ce-bdc4-0b0000009157$4c510ada-c86b-4815-8820-42cdf82c3d51!4c510ada-c86b-4815-8820-42cdf82c3d51 - asdddddd - 2022-11-08T10:45:32Z - httpd/unix-directory - RDNVCK - - - - - 0 - 0.4809828996658325 - - HTTP/1.1 200 OK - - - + + + + /remote.php/dav/files/cboxbot/eos/project/c/cernbox/New%20folder + + + newproject-c!12202852 + newproject-c!12202851 + New folder + 2022-12-05T16:12:20Z + httpd/unix-directory + SRDNVCKZ + + + + + 416606 + + HTTP/1.1 200 OK + + + + /remote.php/dav/files/cboxbot/eos/project/c/cernbox/New%20folder/New%20file.txt + + + newproject-c!12202853 + newproject-c!12202852 + New file.txt + 2022-12-05T16:12:20Z + text/plain + SRDNVCKZ + + + 30 + + HTTP/1.1 200 OK + + + ` w.Write([]byte(data)) w.WriteHeader(207) diff --git a/pkg/eosclient/eosbinary/eosbinary.go b/pkg/eosclient/eosbinary/eosbinary.go index 7f840e5ec03..74ba672b5d8 100644 --- a/pkg/eosclient/eosbinary/eosbinary.go +++ b/pkg/eosclient/eosbinary/eosbinary.go @@ -720,11 +720,11 @@ 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) { // TODO(salfagem): path is truncated - i.e. /c/cernbox (not absolute) - args := []string{"newfind", "--fileinfo", "-name", searchString, path} + args := []string{"newfind", "--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") { + if !strings.HasPrefix(path, "/eos/project/t/test") { log.Debug().Msgf("eosbinary - prefix doesn't match") return nil, errors.Errorf("eosclient: search path out of bounds fn=%s", path) } @@ -741,9 +741,12 @@ func (c *Client) SearchDir(ctx context.Context, auth eosclient.Authorization, se case errtypes.NotFound, errtypes.PermissionDenied: log.Debug().Msgf("eosbinary - user had insufficient permissions to search part of the directory") default: - return nil, errors.Wrapf(err, "eosclient: error listing fn=%s", path) + log.Error().Msgf("ERRROR LISTING= %s", stdout) + // There will be errors: + //return nil, errors.Wrapf(err, "eosclient: error listing fn=%s", path) } } + log.Debug().Msgf("eos find stdout= %s", stdout) return c.parseFind(ctx, auth, path, stdout) } diff --git a/pkg/storage/utils/eosfs/eosfs.go b/pkg/storage/utils/eosfs/eosfs.go index 53209e50fc6..511626f1c0b 100644 --- a/pkg/storage/utils/eosfs/eosfs.go +++ b/pkg/storage/utils/eosfs/eosfs.go @@ -1336,7 +1336,7 @@ func (fs *eosfs) ListFolder(ctx context.Context, ref *provider.Reference, mdKeys // - also check that searchString not empty: searchString = mdKeys[i+1] - log.Info().Msgf("eosfs: running search: path=%s searchString=%s", p, searchString) + log.Debug().Msgf("eosfs: running search: path=%s searchString=%s", p, searchString) eosFileInfos, err := fs.c.SearchDir(ctx, auth, searchString, p) if err != nil { @@ -1353,6 +1353,7 @@ func (fs *eosfs) ListFolder(ctx context.Context, ref *provider.Reference, mdKeys } if finfo, err := fs.convertToFileReference(ctx, eosFileInfo); err == nil { + log.Debug().Msgf("eosfs: file name from search %s", finfo.Name) finfos = append(finfos, finfo) } }