Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add storageID to the special items, improve code #4356

Merged
merged 1 commit into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/unreleased/special-items-improvements.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: Use storageID when requesting special items

We need to use the storageID when requesting the special items of a space to spare a registry lookup and improve the performance

https://github.com/owncloud/ocis/pull/4356
6 changes: 4 additions & 2 deletions services/graph/pkg/service/v0/driveitems.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ func (g Graph) GetExtendedSpaceProperties(ctx context.Context, baseURL *url.URL,
for _, itemName := range names {
if itemID, ok := metadata[itemName]; ok {
rid, _ := storagespace.ParseID(string(itemID.Value))
// add the storageID of the space, all drive items of this space belong to the same storageID
rid.StorageId = space.GetRoot().GetStorageId()
spaceItem := g.getSpecialDriveItem(ctx, rid, itemName, baseURL, space)
if spaceItem != nil {
spaceItems = append(spaceItems, *spaceItem)
Expand All @@ -244,12 +246,12 @@ func (g Graph) getSpecialDriveItem(ctx context.Context, id storageprovider.Resou

spaceItem, err := g.getDriveItem(ctx, id)
if err != nil {
g.logger.Error().Err(err).Str("ID", id.OpaqueId).Msg("Could not get readme Item")
g.logger.Error().Err(err).Str("ID", id.OpaqueId).Str("name", itemName).Msg("Could not get item info")
return nil
}
itemPath, err := g.getPathForResource(ctx, id)
if err != nil {
g.logger.Error().Err(err).Str("ID", id.OpaqueId).Msg("Could not get readme path")
g.logger.Error().Err(err).Str("ID", id.OpaqueId).Str("name", itemName).Msg("Could not get item path")
return nil
}
spaceItem.SpecialFolder = &libregraph.SpecialFolder{Name: libregraph.PtrString(itemName)}
Expand Down
6 changes: 3 additions & 3 deletions services/graph/pkg/service/v0/drives.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,7 @@ func (g Graph) ListStorageSpacesWithFilters(ctx context.Context, filters []*stor
if err != nil {
return nil, err
}

res, err := client.ListStorageSpaces(ctx, &storageprovider.ListStorageSpacesRequest{
lReq := &storageprovider.ListStorageSpacesRequest{
Opaque: &types.Opaque{Map: map[string]*types.OpaqueEntry{
"permissions": {
Decoder: "json",
Expand All @@ -447,7 +446,8 @@ func (g Graph) ListStorageSpacesWithFilters(ctx context.Context, filters []*stor
},
}},
Filters: filters,
})
}
res, err := client.ListStorageSpaces(ctx, lReq)
return res, err
}

Expand Down