mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-11-27 10:34:42 -05:00
fix(graph): give a share root among the search hits no parent path
The share root is the root of the mountpoint drive. Described as a child of / there, driveId, path and name led to a folder of the same name inside the share.
This commit is contained in:
1 parent
d1eda59b34
commit
6431df692f
2 files changed
+28
-3
No files matched your search
@@ -202,12 +202,19 @@ func searchEntityToDriveItem(e *searchmsg.Entity, uid string) *libregraph.DriveI
|
||||
if p := e.GetParentId(); p != nil {
|
||||
ref := libregraph.NewItemReference()
|
||||
ref.SetDriveId(storagespace.FormatStorageID(p.GetStorageId(), p.GetSpaceId()))
|
||||
refPath := e.GetRef().GetPath()
|
||||
// the path of a hit in a share is relative to the mountpoint, so that is the drive
|
||||
if mountpoint := e.GetRef().GetResourceId(); mountpoint != nil && e.GetRemoteItemId() != nil {
|
||||
mountpoint := e.GetRef().GetResourceId()
|
||||
inShare := mountpoint != nil && e.GetRemoteItemId() != nil
|
||||
if inShare {
|
||||
ref.SetDriveId(searchResourceID(mountpoint))
|
||||
}
|
||||
ref.SetId(searchResourceID(p))
|
||||
if refPath := e.GetRef().GetPath(); refPath != "" {
|
||||
// the share root is the root of that drive and has no parent in it
|
||||
isShareRoot := inShare && path.Join("/", refPath) == "/"
|
||||
if !isShareRoot {
|
||||
ref.SetId(searchResourceID(p))
|
||||
}
|
||||
if refPath != "" && !isShareRoot {
|
||||
// the index keeps paths relative to the space root (./dir/file)
|
||||
parent := path.Dir(path.Join("/", refPath))
|
||||
ref.SetPath(parent)
|
||||
|
||||
@@ -254,6 +254,24 @@ var _ = ginkgo.Describe("SearchQuery", func() {
|
||||
Expect(parent.Path).To(Equal("/2026"))
|
||||
})
|
||||
|
||||
ginkgo.It("gives the share root itself no parent in the drive of the mountpoint", func() {
|
||||
g, _ := graphWithSearchAnswer(oneMatch(&searchmsg.Entity{
|
||||
Id: &searchmsg.ResourceID{StorageId: "1", SpaceId: "2", OpaqueId: "5"},
|
||||
ParentId: &searchmsg.ResourceID{StorageId: "1", SpaceId: "2", OpaqueId: "4"},
|
||||
Ref: &searchmsg.Reference{ResourceId: &searchmsg.ResourceID{StorageId: "jail", SpaceId: "jail", OpaqueId: "share"}, Path: "."},
|
||||
RemoteItemId: &searchmsg.ResourceID{StorageId: "1", SpaceId: "2", OpaqueId: "5"},
|
||||
Name: "Project X",
|
||||
}))
|
||||
rr := postSearchQuery(g, searchQueryBody(`"from": 0`))
|
||||
Expect(rr.Code).To(Equal(http.StatusOK), rr.Body.String())
|
||||
|
||||
parent := hitsContainer(rr).Hits[0].Resource.ParentReference
|
||||
Expect(parent.DriveId).To(Equal("jail$jail!share"))
|
||||
Expect(parent.Id).To(BeEmpty())
|
||||
Expect(parent.Path).To(BeEmpty())
|
||||
Expect(parent.Name).To(BeNil())
|
||||
})
|
||||
|
||||
ginkgo.DescribeTable("validatePagination enforces the spec's from/size bounds",
|
||||
func(from, size *int32, wantErr bool) {
|
||||
err := validatePagination(from, size)
|
||||
|
||||
Reference in new issue
Block a user