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

Commit 732bd8b

Browse files
committed
eosbinary: change name parameter and sandbox project
1 parent 799351d commit 732bd8b

File tree

3 files changed

+154
-35
lines changed

3 files changed

+154
-35
lines changed

internal/http/services/owncloud/ocdav/report.go

Lines changed: 146 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func (s *svc) doSearchFiles(w http.ResponseWriter, r *http.Request, sf *reportSe
8989
}
9090

9191
// TODO(salfagem): hardcoded path for the time being:
92-
ref := &provider.Reference{Path: "/eos/project/c/cernbox"}
92+
ref := &provider.Reference{Path: "/eos/project/t/test"}
9393

9494
req := &provider.ListContainerRequest{Opaque: &typespb.Opaque{
9595
Map: opaqueMap,
@@ -103,52 +103,167 @@ func (s *svc) doSearchFiles(w http.ResponseWriter, r *http.Request, sf *reportSe
103103
return
104104
}
105105

106+
log.Debug().Msgf("search: found %d matches", len(res.Infos))
107+
106108
for _, v := range res.Infos {
107109
log.Debug().Msg(v.Path)
108110
}
109111

110112
data := `
111-
<?xml version="1.0" encoding="UTF-8"?>
112113
<d:multistatus xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns" xmlns:s="http://sabredav.org/ns">
113-
<d:response>
114-
<d:href>/remote.php/dav/spaces/1284d238-aa92-42ce-bdc4-0b0000009157$4c510ada-c86b-4815-8820-42cdf82c3d51/asd.txt</d:href>
114+
<d:response>
115+
<d:href>/remote.php/dav/files/cboxbot/eos/project/a/awesomeproject/New%20Text%20Document.txt</d:href>
116+
<d:propstat>
117+
<d:prop>
118+
<oc:fileid>newproject-a!420307062</oc:fileid>
119+
<oc:file-parent>newproject-a!616510</oc:file-parent>
120+
<oc:name>New Text Document.txt</oc:name>
121+
<d:getlastmodified>2022-12-05T16:12:20Z</d:getlastmodified>
122+
<d:getcontenttype>text/plain</d:getcontenttype>
123+
<oc:permissions>SRDNVCKZ</oc:permissions>
124+
<d:getetag />
125+
<d:resourcetype>
126+
<d:collection />
127+
</d:resourcetype>
128+
<oc:size>0</oc:size>
129+
</d:prop>
130+
<d:status>HTTP/1.1 200 OK</d:status>
131+
</d:propstat>
132+
</d:response>
133+
<d:response>
134+
<d:href>/remote.php/dav/files/cboxbot/eos/project/a/awesomeproject/New%20text%20file.txt</d:href>
115135
<d:propstat>
116-
<d:prop>
117-
<oc:fileid>1284d238-aa92-42ce-bdc4-0b0000009157$4c510ada-c86b-4815-8820-42cdf82c3d51!d5613880-307c-4e3e-b56d-97839fcf6d03</oc:fileid>
118-
<oc:file-parent>1284d238-aa92-42ce-bdc4-0b0000009157$4c510ada-c86b-4815-8820-42cdf82c3d51!4c510ada-c86b-4815-8820-42cdf82c3d51</oc:file-parent>
119-
<oc:name>asd.txt</oc:name>
120-
<d:getlastmodified>2022-11-08T10:45:16Z</d:getlastmodified>
136+
<d:prop>
137+
<oc:fileid>newproject-a!166399624</oc:fileid>
138+
<oc:file-parent>newproject-a!616510</oc:file-parent>
139+
<oc:name>New text file.txt</oc:name>
140+
<d:getlastmodified>2022-12-05T16:12:20Z</d:getlastmodified>
121141
<d:getcontenttype>text/plain</d:getcontenttype>
122-
<oc:permissions>RDNVW</oc:permissions>
142+
<oc:permissions>SRDNVCKZ</oc:permissions>
123143
<d:getetag />
124-
<d:resourcetype />
125-
<d:getcontentlength>0</d:getcontentlength>
126-
<oc:score>0.4809828996658325</oc:score>
127-
</d:prop>
128-
<d:status>HTTP/1.1 200 OK</d:status>
144+
<d:resourcetype>
145+
<d:collection />
146+
</d:resourcetype>
147+
<oc:size>5</oc:size>
148+
</d:prop>
149+
<d:status>HTTP/1.1 200 OK</d:status>
129150
</d:propstat>
130-
</d:response>
131-
<d:response>
132-
<d:href>/remote.php/dav/spaces/1284d238-aa92-42ce-bdc4-0b0000009157$4c510ada-c86b-4815-8820-42cdf82c3d51/asdddddd</d:href>
151+
</d:response>
152+
<d:response>
153+
<d:href>/remote.php/dav/files/cboxbot/eos/project/a/awesomeproject/recover.txt</d:href>
133154
<d:propstat>
134-
<d:prop>
135-
<oc:fileid>1284d238-aa92-42ce-bdc4-0b0000009157$4c510ada-c86b-4815-8820-42cdf82c3d51!fa3c7a85-5fc4-46d3-a0b1-293a282da1b7</oc:fileid>
136-
<oc:file-parent>1284d238-aa92-42ce-bdc4-0b0000009157$4c510ada-c86b-4815-8820-42cdf82c3d51!4c510ada-c86b-4815-8820-42cdf82c3d51</oc:file-parent>
137-
<oc:name>asdddddd</oc:name>
138-
<d:getlastmodified>2022-11-08T10:45:32Z</d:getlastmodified>
139-
<d:getcontenttype>httpd/unix-directory</d:getcontenttype>
140-
<oc:permissions>RDNVCK</oc:permissions>
155+
<d:prop>
156+
<oc:fileid>newproject-a!493427700</oc:fileid>
157+
<oc:file-parent>newproject-a!616510</oc:file-parent>
158+
<oc:name>recover.txt</oc:name>
159+
<d:getlastmodified>2022-12-05T16:12:20Z</d:getlastmodified>
160+
<d:getcontenttype>text/plain</d:getcontenttype>
161+
<oc:permissions>SRDNVCKZ</oc:permissions>
141162
<d:getetag />
142163
<d:resourcetype>
143-
<d:collection />
164+
<d:collection />
144165
</d:resourcetype>
145166
<oc:size>0</oc:size>
146-
<oc:score>0.4809828996658325</oc:score>
147-
</d:prop>
148-
<d:status>HTTP/1.1 200 OK</d:status>
167+
</d:prop>
168+
<d:status>HTTP/1.1 200 OK</d:status>
169+
</d:propstat>
170+
</d:response>
171+
<d:response>
172+
<d:href>/remote.php/dav/files/cboxbot/eos/project/a/awesomeproject/test_support.txt</d:href>
173+
<d:propstat>
174+
<d:prop>
175+
<oc:fileid>newproject-a!420300390</oc:fileid>
176+
<oc:file-parent>newproject-a!616510</oc:file-parent>
177+
<oc:name>test_support.txt</oc:name>
178+
<d:getlastmodified>2022-12-05T16:12:20Z</d:getlastmodified>
179+
<d:getcontenttype>text/plain</d:getcontenttype>
180+
<oc:permissions>SRDNVCKZ</oc:permissions>
181+
<d:getetag />
182+
<d:resourcetype>
183+
<d:collection />
184+
</d:resourcetype>
185+
<oc:size>0</oc:size>
186+
</d:prop>
187+
<d:status>HTTP/1.1 200 OK</d:status>
188+
</d:propstat>
189+
</d:response>
190+
<d:response>
191+
<d:href>/remote.php/dav/files/cboxbot/eos/project/a/awesomeproject/testing.txt</d:href>
192+
<d:propstat>
193+
<d:prop>
194+
<oc:fileid>newproject-a!420300167</oc:fileid>
195+
<oc:file-parent>newproject-a!616510</oc:file-parent>
196+
<oc:name>testing.txt</oc:name>
197+
<d:getlastmodified>2022-12-05T16:12:20Z</d:getlastmodified>
198+
<d:getcontenttype>text/plain</d:getcontenttype>
199+
<oc:permissions>SRDNVCKZ</oc:permissions>
200+
<d:getetag />
201+
<d:resourcetype>
202+
<d:collection />
203+
</d:resourcetype>
204+
<oc:size>0</oc:size>
205+
</d:prop>
206+
<d:status>HTTP/1.1 200 OK</d:status>
207+
</d:propstat>
208+
</d:response>
209+
<d:response>
210+
<d:href>/remote.php/dav/files/cboxbot/eos/project/a/awesomeproject/testing2.txt</d:href>
211+
<d:propstat>
212+
<d:prop>
213+
<oc:fileid>newproject-a!420300326</oc:fileid>
214+
<oc:file-parent>newproject-a!616510</oc:file-parent>
215+
<oc:name>testing2.txt</oc:name>
216+
<d:getlastmodified>2022-12-05T16:12:20Z</d:getlastmodified>
217+
<d:getcontenttype>text/plain</d:getcontenttype>
218+
<oc:permissions>SRDNVCKZ</oc:permissions>
219+
<d:getetag />
220+
<d:resourcetype>
221+
<d:collection />
222+
</d:resourcetype>
223+
<oc:size>0</oc:size>
224+
</d:prop>
225+
<d:status>HTTP/1.1 200 OK</d:status>
226+
</d:propstat>
227+
</d:response>
228+
<d:response>
229+
<d:href>/remote.php/dav/files/cboxbot/eos/project/a/awesomeproject/Denied%20Folder/New%20file.txt</d:href>
230+
<d:propstat>
231+
<d:prop>
232+
<oc:fileid>newproject-a!437033942</oc:fileid>
233+
<oc:file-parent>newproject-a!67942728</oc:file-parent>
234+
<oc:name>New file.txt</oc:name>
235+
<d:getlastmodified>2022-12-05T16:12:20Z</d:getlastmodified>
236+
<d:getcontenttype>text/plain</d:getcontenttype>
237+
<oc:permissions>SRDNVCKZ</oc:permissions>
238+
<d:getetag />
239+
<d:resourcetype>
240+
<d:collection />
241+
</d:resourcetype>
242+
<oc:size>0</oc:size>
243+
</d:prop>
244+
<d:status>HTTP/1.1 200 OK</d:status>
245+
</d:propstat>
246+
</d:response>
247+
<d:response>
248+
<d:href>/remote.php/dav/files/cboxbot/eos/project/a/awesomeproject/test_versions/test.txt</d:href>
249+
<d:propstat>
250+
<d:prop>
251+
<oc:fileid>newproject-a!506354963</oc:fileid>
252+
<oc:file-parent>newproject-a!73758625</oc:file-parent>
253+
<oc:name>test.txt</oc:name>
254+
<d:getlastmodified>2022-12-05T16:12:20Z</d:getlastmodified>
255+
<d:getcontenttype>text/plain</d:getcontenttype>
256+
<oc:permissions>SRDNVCKZ</oc:permissions>
257+
<d:getetag />
258+
<d:resourcetype>
259+
<d:collection />
260+
</d:resourcetype>
261+
<oc:size>9</oc:size>
262+
</d:prop>
263+
<d:status>HTTP/1.1 200 OK</d:status>
149264
</d:propstat>
150-
</d:response>
151-
</d:multistatus>
265+
</d:response>
266+
</d:multistatus>
152267
`
153268
w.Write([]byte(data))
154269
w.WriteHeader(207)

pkg/eosclient/eosbinary/eosbinary.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -720,11 +720,11 @@ func (c *Client) List(ctx context.Context, auth eosclient.Authorization, path st
720720
// List the contents of the directory given by path with depth infinity
721721
func (c *Client) SearchDir(ctx context.Context, auth eosclient.Authorization, searchString string, path string) ([]*eosclient.FileInfo, error) {
722722
// TODO(salfagem): path is truncated - i.e. /c/cernbox (not absolute)
723-
args := []string{"newfind", "--fileinfo", "-name", searchString, path}
723+
args := []string{"newfind", "--fileinfo", "--name", searchString, path}
724724
log := appctx.GetLogger(ctx)
725725
log.Debug().Msgf("eosbinary search with args: %s", args)
726726
// Safeguard #2 to prevent the search to go to undesired places:
727-
if !strings.HasPrefix(path, "/eos/project/c/cernbox") {
727+
if !strings.HasPrefix(path, "/eos/project/t/test") {
728728
log.Debug().Msgf("eosbinary - prefix doesn't match")
729729
return nil, errors.Errorf("eosclient: search path out of bounds fn=%s", path)
730730
}
@@ -741,9 +741,12 @@ func (c *Client) SearchDir(ctx context.Context, auth eosclient.Authorization, se
741741
case errtypes.NotFound, errtypes.PermissionDenied:
742742
log.Debug().Msgf("eosbinary - user had insufficient permissions to search part of the directory")
743743
default:
744-
return nil, errors.Wrapf(err, "eosclient: error listing fn=%s", path)
744+
log.Error().Msgf("ERRROR LISTING= %s", stdout)
745+
// There will be errors:
746+
//return nil, errors.Wrapf(err, "eosclient: error listing fn=%s", path)
745747
}
746748
}
749+
log.Debug().Msgf("eos find stdout= %s", stdout)
747750
return c.parseFind(ctx, auth, path, stdout)
748751
}
749752

pkg/storage/utils/eosfs/eosfs.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1336,7 +1336,7 @@ 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-
log.Info().Msgf("eosfs: running search: path=%s searchString=%s", p, searchString)
1339+
log.Debug().Msgf("eosfs: running search: path=%s searchString=%s", p, searchString)
13401340

13411341
eosFileInfos, err := fs.c.SearchDir(ctx, auth, searchString, p)
13421342
if err != nil {
@@ -1353,6 +1353,7 @@ func (fs *eosfs) ListFolder(ctx context.Context, ref *provider.Reference, mdKeys
13531353
}
13541354

13551355
if finfo, err := fs.convertToFileReference(ctx, eosFileInfo); err == nil {
1356+
log.Debug().Msgf("eosfs: file name from search %s", finfo.Name)
13561357
finfos = append(finfos, finfo)
13571358
}
13581359
}

0 commit comments

Comments
 (0)