Skip to content

Commit

Permalink
add remote item metadata
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Barz <[email protected]>
  • Loading branch information
micbar committed Jun 13, 2023
1 parent 85dcb57 commit e4e1bb4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/add-remote-item-metadata.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: Add more metadata to the remote item

We added the drive alias, the space name and the relative path to the remote item. This is needed to resolve shared files directly on the source space.

https://github.com/owncloud/ocis/pull/6300
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 @@ -129,7 +129,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 @@ -192,8 +192,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 @@ -211,6 +211,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 e4e1bb4

Please sign in to comment.