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

[full-ci] Unify id format #3185

Merged
merged 7 commits into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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/unify-file-ids.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Change: Unify file IDs

We changed the file IDs to be consistent across all our APIs (WebDAV, LibreGraph, OCS). We removed the base64 encoding. Now they are formatted like <storageID>!<opaqueID>. They are using a reserved character ``!`` as a URL safe separator.

https://github.com/owncloud/ocis/pull/3185
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -266,3 +266,5 @@ require (

// we need to use a fork to make the windows build pass
replace github.com/pkg/xattr => github.com/micbar/xattr v0.4.6-0.20220215112335-88e74d648fb7

replace github.com/cs3org/reva => github.com/micbar/reva v1.9.1-0.20220216163611-c8b1d89c4f8b
micbar marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,6 @@ github.com/crewjam/saml v0.4.5/go.mod h1:qCJQpUtZte9R1ZjUBcW8qtCNlinbO363ooNl02S
github.com/cs3org/cato v0.0.0-20200828125504-e418fc54dd5e/go.mod h1:XJEZ3/EQuI3BXTp/6DUzFr850vlxq11I6satRtz0YQ4=
github.com/cs3org/go-cs3apis v0.0.0-20220126114148-64c025ccdd19 h1:1jqPH58jCxvbaJ9WLIJ7W2/m622bWS6ChptzljSG6IQ=
github.com/cs3org/go-cs3apis v0.0.0-20220126114148-64c025ccdd19/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY=
github.com/cs3org/reva v1.16.1-0.20220214105747-d217886c962b h1:E53EHbKiHIIJeZgDEx5tE3AflxgL1dHughNbBQU7Dfk=
github.com/cs3org/reva v1.16.1-0.20220214105747-d217886c962b/go.mod h1:gdKuhou74V47snANuHNIhGNJfCKUSCHPPvuhSx7nu5M=
github.com/cs3org/reva v1.16.1-0.20220215130802-df1264deff58 h1:CBSpClYZp8Q7Cl/xENW42Zy7M9+vqACAulqXFnWn3Ug=
github.com/cs3org/reva v1.16.1-0.20220215130802-df1264deff58/go.mod h1:gdKuhou74V47snANuHNIhGNJfCKUSCHPPvuhSx7nu5M=
github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8 h1:Z9lwXumT5ACSmJ7WGnFl+OMLLjpz5uR2fyz7dC255FI=
github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8/go.mod h1:4abs/jPXcmJzYoYGF91JF9Uq9s/KL5n1jvFDix8KcqY=
github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4=
Expand Down Expand Up @@ -1001,6 +997,8 @@ github.com/mendsley/gojwk v0.0.0-20141217222730-4d5ec6e58103 h1:Z/i1e+gTZrmcGeZy
github.com/mendsley/gojwk v0.0.0-20141217222730-4d5ec6e58103/go.mod h1:o9YPB5aGP8ob35Vy6+vyq3P3bWe7NQWzf+JLiXCiMaE=
github.com/mennanov/fieldmask-utils v0.5.0 h1:8em4akN0NM3hmmrg8VbvOPfdS4SSBdbFd53m9VtfOg0=
github.com/mennanov/fieldmask-utils v0.5.0/go.mod h1:lah2lHczE2ff+7SqnNKpB+YzaO7M3h5iNO4LgPTJheM=
github.com/micbar/reva v1.9.1-0.20220216163611-c8b1d89c4f8b h1:LoS2H6RNMEd+NVlq95WsZXaPvIpj3FABG12zYewhv18=
github.com/micbar/reva v1.9.1-0.20220216163611-c8b1d89c4f8b/go.mod h1:gdKuhou74V47snANuHNIhGNJfCKUSCHPPvuhSx7nu5M=
github.com/micbar/xattr v0.4.6-0.20220215112335-88e74d648fb7 h1:M0R40eUlyqxMuZn3Knx4DJTwHE3TiPFzcWUA/BKtDMM=
github.com/micbar/xattr v0.4.6-0.20220215112335-88e74d648fb7/go.mod h1:sBD3RAqlr8Q+RC3FutZcikpT8nyDrIEEBw2J744gVWs=
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
Expand Down
17 changes: 9 additions & 8 deletions graph/pkg/service/v0/driveitems.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
cs3rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
storageprovider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
types "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
"github.com/cs3org/reva/pkg/utils/resourceid"
"github.com/go-chi/render"
libregraph "github.com/owncloud/libre-graph-api-go"
"github.com/owncloud/ocis/graph/pkg/service/v0/errorcode"
Expand Down Expand Up @@ -113,7 +114,7 @@ func cs3ResourceToDriveItem(res *storageprovider.ResourceInfo) (*libregraph.Driv
*size = int64(res.Size) // TODO lurking overflow: make size of libregraph drive item use uint64

driveItem := &libregraph.DriveItem{
Id: &res.Id.OpaqueId,
Id: libregraph.PtrString(resourceid.OwnCloudResourceIDWrap(res.Id)),
Size: size,
}

Expand Down Expand Up @@ -164,7 +165,7 @@ func (g Graph) GetExtendedSpaceProperties(ctx context.Context, baseURL *url.URL,

for _, itemName := range names {
if itemID, ok := metadata[itemName]; ok {
spaceItem := g.getSpecialDriveItem(ctx, string(itemID.Value), itemName, baseURL, space)
spaceItem := g.getSpecialDriveItem(ctx, resourceid.OwnCloudResourceIDUnwrap(string(itemID.Value)), itemName, baseURL, space)
if spaceItem != nil {
spaceItems = append(spaceItems, *spaceItem)
}
Expand All @@ -173,20 +174,20 @@ func (g Graph) GetExtendedSpaceProperties(ctx context.Context, baseURL *url.URL,
return spaceItems
}

func (g Graph) getSpecialDriveItem(ctx context.Context, itemID string, itemName string, baseURL *url.URL, space *storageprovider.StorageSpace) *libregraph.DriveItem {
func (g Graph) getSpecialDriveItem(ctx context.Context, ID *storageprovider.ResourceId, itemName string, baseURL *url.URL, space *storageprovider.StorageSpace) *libregraph.DriveItem {
var spaceItem *libregraph.DriveItem
if itemID == "" {
if ID == nil {
return nil
}

spaceItem, err := g.getDriveItem(ctx, &storageprovider.ResourceId{StorageId: space.Root.StorageId, OpaqueId: itemID})
spaceItem, err := g.getDriveItem(ctx, ID)
if err != nil {
g.logger.Error().Err(err).Str("ID", itemID).Msg("Could not get readme Item")
g.logger.Error().Err(err).Str("ID", ID.OpaqueId).Msg("Could not get readme Item")
return nil
}
itemPath, err := g.getPathForDriveItem(ctx, &storageprovider.ResourceId{StorageId: space.Root.StorageId, OpaqueId: itemID})
itemPath, err := g.getPathForDriveItem(ctx, ID)
if err != nil {
g.logger.Error().Err(err).Str("ID", itemID).Msg("Could not get readme path")
g.logger.Error().Err(err).Str("ID", ID.OpaqueId).Msg("Could not get readme path")
return nil
}
spaceItem.SpecialFolder = &libregraph.SpecialFolder{Name: libregraph.PtrString(itemName)}
Expand Down
3 changes: 2 additions & 1 deletion graph/pkg/service/v0/drives.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
types "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
ctxpkg "github.com/cs3org/reva/pkg/ctx"
"github.com/cs3org/reva/pkg/utils"
"github.com/cs3org/reva/pkg/utils/resourceid"
"github.com/go-chi/chi/v5"
"github.com/go-chi/render"
libregraph "github.com/owncloud/libre-graph-api-go"
Expand Down Expand Up @@ -409,7 +410,7 @@ func (g Graph) ListStorageSpacesWithFilters(ctx context.Context, filters []*stor
}

func (g Graph) cs3StorageSpaceToDrive(baseURL *url.URL, space *storageprovider.StorageSpace) (*libregraph.Drive, error) {
rootID := space.Root.StorageId + "!" + space.Root.OpaqueId
rootID := resourceid.OwnCloudResourceIDWrap(space.Root)
if space.Root.StorageId == space.Root.OpaqueId {
// omit opaqueid
rootID = space.Root.StorageId
Expand Down