Skip to content

Commit

Permalink
add remote item metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
micbar committed May 16, 2023
1 parent 28e6ec7 commit dde48a5
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions services/graph/pkg/service/v0/driveitems.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (g Graph) getRemoteItem(ctx context.Context, root *storageprovider.Resource
// TODO how do we build the url?
// for now: read from request
webDavURL := *baseURL
webDavURL.Path = path.Join(webDavURL.Path, storagespace.FormatResourceID(*root))
webDavURL.Path = path.Join(webDavURL.Path, storagespace.FormatResourceID(*res.GetInfo().GetSpace().GetRoot()), res.GetInfo().GetPath())
item.WebDavUrl = libregraph.PtrString(webDavURL.String())
}
return item, nil
Expand Down Expand Up @@ -181,8 +181,8 @@ func cs3ResourceToRemoteItem(res *storageprovider.ResourceInfo) (*libregraph.Rem
Size: size,
}

if name := path.Base(res.Path); name != "" {
remoteItem.Name = &name
if res.GetPath() != "" {
remoteItem.Path = libregraph.PtrString(path.Clean(res.GetPath()))
}
if res.Etag != "" {
remoteItem.ETag = &res.Etag
Expand All @@ -200,6 +200,14 @@ func cs3ResourceToRemoteItem(res *storageprovider.ResourceInfo) (*libregraph.Rem
if res.Type == storageprovider.ResourceType_RESOURCE_TYPE_CONTAINER {
remoteItem.Folder = &libregraph.Folder{}
}
if res.GetSpace() != nil {
remoteItem.RootId = libregraph.PtrString(storagespace.FormatResourceID(*res.GetSpace().GetRoot()))
grantSpaceAlias := utils.ReadPlainFromOpaque(res.GetSpace().GetOpaque(), "spaceAlias")
if grantSpaceAlias != "" {
remoteItem.DriveAlias = libregraph.PtrString(grantSpaceAlias)
}
remoteItem.Name = libregraph.PtrString(res.GetSpace().GetName())
}
return remoteItem, nil
}

Expand Down

0 comments on commit dde48a5

Please sign in to comment.