Skip to content

Commit

Permalink
update to embedded reference
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
  • Loading branch information
butonic committed Jun 15, 2021
1 parent e7fd289 commit bb23e7b
Show file tree
Hide file tree
Showing 33 changed files with 111 additions and 138 deletions.
4 changes: 1 addition & 3 deletions cmd/reva/open-in-app.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ func openInAppCommand() *command {
return err
}

ref := &provider.Reference{
Path: path,
}
ref := &provider.Reference{Path: path}

opaqueObj := &typespb.Opaque{
Map: map[string]*typespb.OpaqueEntry{},
Expand Down
7 changes: 2 additions & 5 deletions cmd/reva/recycle-list.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,8 @@ func recycleListCommand() *command {
return err
}

req := &gateway.ListRecycleRequest{
Ref: &provider.Reference{
Path: getHomeRes.Path,
},
}
req := &gateway.ListRecycleRequest{Ref: &provider.Reference{Path: getHomeRes.Path}}

res, err := client.ListRecycle(ctx, req)
if err != nil {
return err
Expand Down
6 changes: 1 addition & 5 deletions cmd/reva/recycle-purge.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@ func recyclePurgeCommand() *command {
return err
}

req := &gateway.PurgeRecycleRequest{
Ref: &provider.Reference{
Path: getHomeRes.Path,
},
}
req := &gateway.PurgeRecycleRequest{Ref: &provider.Reference{Path: getHomeRes.Path}}

res, err := client.PurgeRecycle(ctx, req)
if err != nil {
Expand Down
4 changes: 1 addition & 3 deletions cmd/reva/recycle-restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ func recycleRestoreCommand() *command {
}

req := &provider.RestoreRecycleItemRequest{
Ref: &provider.Reference{
Path: getHomeRes.Path,
},
Ref: &provider.Reference{Path: getHomeRes.Path},
Key: key,
}

Expand Down
3 changes: 1 addition & 2 deletions cmd/reva/share-create.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ func shareCreateCommand() *command {
return err
}

ref := &provider.Reference{Path: fn}
req := &provider.StatRequest{Ref: ref}
req := &provider.StatRequest{Ref: &provider.Reference{Path: fn}}
res, err := client.Stat(ctx, req)
if err != nil {
return err
Expand Down
3 changes: 1 addition & 2 deletions cmd/reva/stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ func statCommand() *command {
return err
}

ref := &provider.Reference{Path: fn}
req := &provider.StatRequest{Ref: ref}
req := &provider.StatRequest{Ref: &provider.Reference{Path: fn}}
res, err := client.Stat(ctx, req)
if err != nil {
return err
Expand Down
4 changes: 1 addition & 3 deletions cmd/reva/transfer-create.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ func transferCreateCommand() *command {
}

// verify resource stats
statReq := &provider.StatRequest{
Ref: &provider.Reference{Path: fn},
}
statReq := &provider.StatRequest{Ref: &provider.Reference{Path: fn}}
statRes, err := client.Stat(ctx, statReq)
if err != nil {
return err
Expand Down
6 changes: 1 addition & 5 deletions internal/grpc/interceptors/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,7 @@ func dismantleToken(ctx context.Context, tkn string, req interface{}, mgr token.

// Since the public share is obtained from the scope, the current token
// has access to it.
statReq := &provider.StatRequest{
Ref: &provider.Reference{
ResourceId: share.ResourceId,
},
}
statReq := &provider.StatRequest{Ref: &provider.Reference{ResourceId: share.ResourceId}}

statResponse, err := client.Stat(ctx, statReq)
if err != nil || statResponse.Status.Code != rpc.Code_CODE_OK {
Expand Down
30 changes: 14 additions & 16 deletions internal/grpc/services/gateway/storageprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (s *svc) ListStorageSpaces(ctx context.Context, req *provider.ListStorageSp
}, nil
}
c, err := s.find(ctx, &provider.Reference{ResourceId: &provider.ResourceId{
StorageId: parts[0], // FIXME REFERENCE the StorageSpaceId is a storageid + a opaqueid
StorageId: parts[0], // FIXME REFERENCE the StorageSpaceId is a storageid + an opaqueid
OpaqueId: parts[1],
}})
if err != nil {
Expand Down Expand Up @@ -318,9 +318,7 @@ func (s *svc) InitiateFileDownload(ctx context.Context, req *provider.InitiateFi
log.Debug().Msgf("shared child: %s", p)
shareName, shareChild := s.splitShare(ctx, p)

statReq := &provider.StatRequest{
Ref: &provider.Reference{Path: shareName},
}
statReq := &provider.StatRequest{Ref: &provider.Reference{Path: shareName}}
statRes, err := s.stat(ctx, statReq)
if err != nil {
return &gateway.InitiateFileDownloadResponse{
Expand Down Expand Up @@ -1346,13 +1344,11 @@ func (s *svc) handleCS3Ref(ctx context.Context, opaque string) (*provider.Resour
// we could call here the Stat method again, but that is calling for problems in case
// there is a loop of targets pointing to targets, so better avoid it.

req := &provider.StatRequest{
Ref: &provider.Reference{
ResourceId: &provider.ResourceId{
StorageId: parts[0],
OpaqueId: parts[1],
},
},
req := &provider.StatRequest{Ref: &provider.Reference{
ResourceId: &provider.ResourceId{
StorageId: parts[0],
OpaqueId: parts[1],
}},
}
res, err := s.stat(ctx, req)
if err != nil {
Expand Down Expand Up @@ -1403,7 +1399,7 @@ func (s *svc) listHome(ctx context.Context, req *provider.ListContainerRequest)
}

for i := range lcr.Infos {
if s.isSharedFolder(ctx, lcr.Infos[i].GetPath()) {
if s.isSharedFolder(ctx, lcr.Infos[i].Path) {
statSharedFolder, err := s.statSharesFolder(ctx)
if err != nil {
return &provider.ListContainerResponse{
Expand All @@ -1424,7 +1420,9 @@ func (s *svc) listHome(ctx context.Context, req *provider.ListContainerRequest)
}

func (s *svc) listSharesFolder(ctx context.Context) (*provider.ListContainerResponse, error) {
lcr, err := s.listContainer(ctx, &provider.ListContainerRequest{Ref: &provider.Reference{Path: s.getSharedFolder(ctx)}})
lcr, err := s.listContainer(ctx, &provider.ListContainerRequest{
Ref: &provider.Reference{Path: s.getSharedFolder(ctx)},
})
if err != nil {
return &provider.ListContainerResponse{
Status: status.NewInternal(ctx, err, "gateway: error listing shared folder"),
Expand Down Expand Up @@ -1455,7 +1453,7 @@ func (s *svc) listSharesFolder(ctx context.Context) (*provider.ListContainerResp
}
}

info.Path = lcr.Infos[i].Path
info.Path = lcr.Infos[i].GetPath()
checkedInfos = append(checkedInfos, info)
}
lcr.Infos = checkedInfos
Expand All @@ -1464,7 +1462,7 @@ func (s *svc) listSharesFolder(ctx context.Context) (*provider.ListContainerResp
}

func isStorageSpaceReference(ref *provider.Reference) bool {
return ref.GetResourceId() != nil && strings.HasPrefix(ref.Path, ".")
return ref.ResourceId != nil && strings.HasPrefix(ref.Path, ".")
}

func (s *svc) listContainer(ctx context.Context, req *provider.ListContainerRequest) (*provider.ListContainerResponse, error) {
Expand Down Expand Up @@ -1746,7 +1744,7 @@ func (s *svc) getPath(ctx context.Context, ref *provider.Reference, keys ...stri
return res.Info.Path, res.Status
}

if ref.Path != "" {
if ref.ResourceId == nil && strings.HasPrefix(ref.Path, "/") {
return ref.Path, &rpc.Status{Code: rpc.Code_CODE_OK}
}
return "", &rpc.Status{Code: rpc.Code_CODE_INTERNAL}
Expand Down
11 changes: 3 additions & 8 deletions internal/grpc/services/gateway/usershareprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,12 +321,11 @@ func (s *svc) UpdateReceivedShare(ctx context.Context, req *collaboration.Update
}

func (s *svc) createReference(ctx context.Context, resourceID *provider.ResourceId) *rpc.Status {
ref := &provider.Reference{
ResourceId: resourceID,
}

log := appctx.GetLogger(ctx)

// get the metadata about the share
ref := &provider.Reference{ResourceId: resourceID}
c, err := s.find(ctx, ref)
if err != nil {
if _, ok := err.(errtypes.IsNotFound); ok {
Expand All @@ -335,11 +334,7 @@ func (s *svc) createReference(ctx context.Context, resourceID *provider.Resource
return status.NewInternal(ctx, err, "error finding storage provider")
}

statReq := &provider.StatRequest{
Ref: ref,
}

statRes, err := c.Stat(ctx, statReq)
statRes, err := c.Stat(ctx, &provider.StatRequest{Ref: ref})
if err != nil {
return status.NewInternal(ctx, err, "gateway: error calling Stat for the share resource id: "+resourceID.String())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ func (s *service) unwrap(ctx context.Context, ref *provider.Reference) (token st
return "", "", errtypes.BadRequest("need absolute path ref: got " + ref.String())
}

if ref.GetPath() == "" {
if !strings.HasPrefix(ref.GetPath(), "/") {
// abort, no valid id nor path
return "", "", errtypes.BadRequest("invalid ref: " + ref.String())
}
Expand Down Expand Up @@ -694,9 +694,7 @@ func (s *service) resolveToken(ctx context.Context, token string) (string, *link
}

sRes, err := s.gateway.Stat(ctx, &provider.StatRequest{
Ref: &provider.Reference{
ResourceId: publicShareResponse.GetShare().GetResourceId(),
},
Ref: &provider.Reference{ResourceId: publicShareResponse.GetShare().GetResourceId()},
})
switch {
case err != nil:
Expand Down
12 changes: 6 additions & 6 deletions internal/grpc/services/storageprovider/storageprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ func (s *service) InitiateFileDownload(ctx context.Context, req *provider.Initia

if isStorageSpaceReference(req.Ref) {
protocol.Protocol = "spaces"
u.Path = path.Join(u.Path, "spaces", req.Ref.ResourceId.StorageId+"!"+req.Ref.ResourceId.OpaqueId)
u.Path = path.Join(u.Path, "spaces", req.Ref.ResourceId.StorageId+"!"+req.Ref.ResourceId.OpaqueId, req.Ref.Path)
} else {
ctx, newRef, err := s.unwrap(ctx, req.Ref)
if err != nil {
Expand Down Expand Up @@ -927,8 +927,8 @@ func (s *service) RestoreRecycleItem(ctx context.Context, req *provider.RestoreR

func (s *service) PurgeRecycle(ctx context.Context, req *provider.PurgeRecycleRequest) (*provider.PurgeRecycleResponse, error) {
// if a key was sent as opaque id purge only that item
if req.GetRef().GetResourceId() != nil && req.GetRef().GetResourceId().OpaqueId != "" {
if err := s.storage.PurgeRecycleItem(ctx, req.GetRef().GetResourceId().OpaqueId); err != nil {
if req.GetRef() != nil && req.GetRef().GetResourceId() != nil && req.GetRef().GetResourceId().OpaqueId != "" {
if err := s.storage.PurgeRecycleItem(ctx, req.GetRef().ResourceId.OpaqueId); err != nil {
var st *rpc.Status
switch err.(type) {
case errtypes.IsNotFound:
Expand Down Expand Up @@ -1183,7 +1183,7 @@ func getFS(c *config) (storage.FS, error) {
}

func (s *service) unwrap(ctx context.Context, ref *provider.Reference) (context.Context, *provider.Reference, error) {
if ref.GetResourceId() != nil {
if ref.ResourceId != nil {
if ref.Path != "" {
// ListStorageSpaces filter by id -> root item
// Get path from root item
Expand All @@ -1196,7 +1196,7 @@ func (s *service) unwrap(ctx context.Context, ref *provider.Reference) (context.
Type: provider.ListStorageSpacesRequest_Filter_TYPE_ID,
Term: &provider.ListStorageSpacesRequest_Filter_Id{
Id: &provider.StorageSpaceId{
OpaqueId: ref.GetResourceId().StorageId + "!" + ref.GetResourceId().OpaqueId,
OpaqueId: ref.ResourceId.StorageId + "!" + ref.ResourceId.OpaqueId,
},
},
},
Expand Down Expand Up @@ -1272,5 +1272,5 @@ func (s *service) wrap(ctx context.Context, ri *provider.ResourceInfo) error {
// In the URL it looks like this: /a-storage-provider-id!a-storage-space-id/optional/relative/path
// See https://github.com/cs3org/cs3apis/pull/125 for an extension to the CS3 ReferenceID to model this properly
func isStorageSpaceReference(ref *provider.Reference) bool {
return ref.GetResourceId() != nil && strings.HasPrefix(ref.Path, ".")
return ref.ResourceId != nil && strings.HasPrefix(ref.Path, ".")
}
4 changes: 2 additions & 2 deletions internal/http/services/owncloud/ocdav/avatars.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (h *AvatarsHandler) Handler(s *svc) http.Handler {
ctx := r.Context()
log := appctx.GetLogger(ctx)

if r.Method == http.MethodOptions {
if r.Method == "OPTIONS" {
// no need for the user, and we need to be able
// to answer preflight checks, which have no auth headers
r.URL.Path = "/" // always use / ... we just want the options answered so phoenix doesnt hiccup
Expand All @@ -49,7 +49,7 @@ func (h *AvatarsHandler) Handler(s *svc) http.Handler {
}

_, r.URL.Path = router.ShiftPath(r.URL.Path)
if r.Method == http.MethodGet && r.URL.Path == "/128.png" {
if r.Method == "GET" && r.URL.Path == "/128.png" {
// TODO load avatar url from user context?
const img = "89504E470D0A1A0A0000000D4948445200000080000000800806000000C33E61CB00000006624B474400FF00FF00FFA0BDA793000000097048597300000B1300000B1301009A9C180000000774494D4507E3061B080516D3ECF61E000008F24944415478DAED9D7D8C1D5515C07FDB76774B775BB7454AA54BBB2D5DDD765B6BD34A140B464CB07EA0113518016B4848FC438A1A448D9A18FF40316942524D544C900F49A17C2882120A28604D506C915AB160B7B2A14275B7BB606BCB76779F7FDC79F4CE79F7BD7DEFED7B3377E69E5FF2B233DBED9B7B3EEECCB977CE3D171445511445511445098B9680645D0BAC8C7EAE020A0E5D0C027B80DDC033EA1ED96521B001D80A3C1F19BB9ECF007003F0CEE83B15CFB90C781A189986D1CB7D8E007F06AE5035FBC599C0359181AA35E6716014188A3EA3D1EFAAFDFFAF025F06DEA2EA4F97EB81935318EB047037F0396035300FE8043A8039D1A723FADD3CA01FB80AB817989CE2BB4F0237AA1992E703C00B150CB313D812057DD36555D4DB7756B8DE41E0236A9664B8A982216E897A72B3980BDC5CE1CE70AB9AA779744541984BF1DF03BA136C4B77F4F871B5E519E074355763590E8C9519A62D4DB15DDDC07E47BBC681156AB6C6D0071C7328F93A60A607ED9B017CDED1BEA35140A94C83259122ED67EE316093876DDD28E61F26A3B69EAD66AC9F61D1AB463D1F7BCF075E126D1E5233D6C74EC7E4CBEA0CB47B317048B4FD6135676D5C2E14F83A705686DA3FD771F7D229E41A823E19507D2A83729CEF90A34FCD3B35F70BA5DD906159AE14B2FC5ACD5B99F384C20E016D19966726B04FC874819AB93C434259EFCD814C2B1C2319C5C14542513FCF916C5B856C17ABB94BF915F1A9D43CCDA2AD20FEDAFA5135779CD9A287FC2D8732EE12322E52B39FE28742391B722863BF90F17635BBA115386C296630C7B2DA492CFFC16423A5CA0C0F94B214938A55E4DE9CC73945E691EEAB6C6F1C605D140314F96D8E1DE009EBB82D923D78EE14CFC63C67DA9E2D64DDA1E687D7882751E49D717452E80DE692DFC99F723C26646E0F390638579C3F1280033CEE888182758035E27C57000EF09438EF0BD9017AC5F940000EB0479CF784EC004BACE362E66FDE1916E7DD213BC07CEBF8BF8104BE72B4B330640768B58E8F0734FA39661D7785EA002DE2FA2703790448676F0DD901EC123593013D02267CB90BCF48591105E110A13051A12304E500E3BEDC0A136666858E105410683B407B20778116605699BB41700E30621DCF09E80E709A757C22640778D93A9E1B501C603BFB70C80EF092753C0B3FD6FB27815DC6E65F213B80CCFFEB0DC0F8B27CCC3F43768003E27C6D000E20339E5F08D9019E9B423979E43C71BE97C0B1B3639E0A40DE3F089983E72FC4EBEAE41DBBDED1F36937C687B4703B55BA050F72E59B488F18EA3EAE0E509A07B826C70E2083DC87D5014C143C669DAFCFB103D8B28D3B82E020E9225EEA3DCF2B839EB4E41C414BCABEC19E4022635BC67D3E346886278AF99138BF3487C6DF2CCE7FA2FD3EEE8876EF78368732CA6251AD6AF6D2D180BDA54B9E6AEC2E25BE25CD633EF53C5FD86E1DCF06DE9D2307D8487C09FC1DDADF4B5981C98E29F692277224DB1F2DB926D0BD04CAF2AC784E2ECB814CB236D05E3573792E10CABA270732FD46C874A19AB9320396B286C9F664C9424C1188A23C2FFA38FCF20D3B185C80D9222EAB7C0C7893757EA7F6EFA9E9A174E3C7AC22B797D3E0AF4AEE168AFB520665F8AA90E101356BF57489DEB39F6C958D6FA77467D337AB59ABA705784828F033196AFF15A2ED8F12D6DAC786B086D22D57B2B07A688EA3DDEBD59CF5F103A1C86D1968F336D1E69FAA19EB6701A6744C5666079789B61ED367FFF4F99650EA11FC5C42D64A3CB3A9007C57CDD7189E168AFDBE876DBC91FCE734A4463F66F3485BC11FF4A87D978AB68D11C632B744B99AD2DD44CFF1A05DEB89BFC62E00D7AAB99AC30EA1E8D7800E8F82BE02709F9AA9799C46E9DE820748A7E2F65B8997BA2F06A81D6AA6E6D289C9A9B7153F98F070EB3D8E9E3F4AFCCD9FD244563B0C3044325BB17DC271ED02F02E354BF2C1D70987219AB9A6E0DA32C6FFA49A231DFACA18647B13AE7553996B6D5333A4CB324CA125DB2813C0CA065EA3D731D42B00B7A9FAFDC136CCFF68ECEE638BA2EF94A38F3655BB1FC8F705CDD87CF23E718D6FAADAFD19168E0AE3346338D625AE314C7CB58F921232FBA6995BCFDD21AEF551557FBAB4736AA38924B26F36503AF9A3A95E29F26002C33F89CC58BE4BCD900E1FA2741E3E89A8BC8D78E2C704F03E3547B2F43AC6E4572778FD2D8EEBF7A859926101F04A0AB77E89DCF5FC1029EF0016024B89EFBE5D00FE413AAF83DB319341765B4E92EF4297A97215A519C2C749E60D603916112FFD52DC14F2323557633803F3EEFD49C73377043F52C2CE1141617149DB4398323767AA19AB6739F005E09798248F51DC6FE00EE357DD80D3817F9769EBAB517CF040143C6AB018B10CB818F80EA61ED0781905CACF0EFC4CBBEAC45434A9468613983AC15F073691AF8A6815E9C1E4CF8F44069FAC5261C5D2EAABF07BE6AD0593A3F05C0D724D46BA18C2AC77E8CE93C1DB804F03B746B7F4420D9F21E07EE02BC0BA0CCADE0F5C8399391CA851F641E076E072329864DA1605463B6A10780CB38E6E2F701D8D7D97EF13E702D7037F8F460B6355EAE741E06D789E7FB004933675A04AA186819B31397C6B896FA516029D98E4D64B22BD1DA9426703C08F7DEA20B380B7535A0ACDF59C3B0CEC06BE019CA531B0933E4C8EE100A51948AE6078252916FADA8829803C51A191AF005FC32CA298AFF6ADA9632D8E628017A77874EE8E3A6162F402BFA8D0A8039852E8FD6AC786B10E938CF27205BD6F4F628EE18B94AED22D7E0E621226B40C7AF368053E4EE9CA287B7E6173332EDC8149B4745DF477C087D53689B3391A4DB86C720B0DAEA774D07191A3C0F96A87D4D952663839D8A85BCE2EC7977F9B6C54EC0A851EE0670E3BED9EEEDCC1FB1D51E73AD5B7B75CE888D12E99CE17CAE95B5D04E93F17519A2B5917B2FAC53ED56D6678840614A9FEACF8924DAAD7CCB0BEDA3B77A569C47788F3DFAB5E33C37E71BEB81E07586E1D1F45F7BACF1AF67ECC67D4E30036AFAB03648A494CB26A91B28B6567D5F0A573D07570596176E40045C3774ED7011670EA3DBFE23F2DC2E8EDF538408B389EA77ACD2C6DF5C40007556FB9E1AFD5F472175762B66D9B2D6EFF05F19332E7D4F877AE7F6FF66327EF8FB53F015BB50F288AA2288AA2288A62F83FEC37068C6750398B0000000049454E44AE426082"
decoded, err := hex.DecodeString(img)
Expand Down
14 changes: 5 additions & 9 deletions internal/http/services/owncloud/ocdav/trashbin.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,7 @@ func (h *TrashbinHandler) restore(w http.ResponseWriter, r *http.Request, s *svc
// this means we can only undelete on the same storage, not to a different folder
// use the key which is prefixed with the StoragePath to lookup the correct storage ...
// TODO currently limited to the home storage
Ref: &provider.Reference{
Path: getHomeRes.Path,
},
Ref: &provider.Reference{Path: getHomeRes.Path},
Key: key,
RestoreRef: &provider.Reference{Path: dst},
}
Expand Down Expand Up @@ -453,12 +451,10 @@ func (h *TrashbinHandler) delete(w http.ResponseWriter, r *http.Request, s *svc,
// storage drives PurgeRecycleItem key call

req := &gateway.PurgeRecycleRequest{
Ref: &provider.Reference{
ResourceId: &provider.ResourceId{
StorageId: sRes.Info.Id.StorageId,
OpaqueId: key,
},
},
Ref: &provider.Reference{ResourceId: &provider.ResourceId{
StorageId: sRes.Info.Id.StorageId,
OpaqueId: key,
}},
}

res, err := client.PurgeRecycle(ctx, req)
Expand Down
4 changes: 2 additions & 2 deletions internal/http/services/owncloud/ocdav/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ func (h *VersionsHandler) doListVersions(w http.ResponseWriter, r *http.Request,
w.WriteHeader(http.StatusInternalServerError)
return
}

ref := &provider.Reference{ResourceId: rid}

res, err := client.Stat(ctx, &provider.StatRequest{Ref: ref})
if err != nil {
sublog.Error().Err(err).Msg("error sending a grpc stat request")
Expand Down Expand Up @@ -137,7 +137,7 @@ func (h *VersionsHandler) doListVersions(w http.ResponseWriter, r *http.Request,
// Opaque
Type: provider.ResourceType_RESOURCE_TYPE_FILE,
Id: &provider.ResourceId{
StorageId: "versions",
StorageId: "versions", // this is a virtual storage
OpaqueId: info.Id.OpaqueId + "@" + versions[i].GetKey(),
},
// Checksum
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,9 +506,7 @@ func (h *Handler) updateShare(w http.ResponseWriter, r *http.Request, shareID st
return
}

statReq := provider.StatRequest{Ref: &provider.Reference{
ResourceId: uRes.Share.ResourceId,
}}
statReq := provider.StatRequest{Ref: &provider.Reference{ResourceId: uRes.Share.ResourceId}}

statRes, err := client.Stat(r.Context(), &statReq)
if err != nil {
Expand Down Expand Up @@ -618,7 +616,7 @@ func (h *Handler) listSharesWithMe(w http.ResponseWriter, r *http.Request) {
var info *provider.ResourceInfo
if pinfo != nil {
// check if the shared resource matches the path resource
if !utils.ResourceEqual(&provider.Reference{ResourceId: rs.Share.ResourceId}, &provider.Reference{ResourceId: pinfo.Id}) {
if !utils.ResourceIDEqual(rs.Share.ResourceId, pinfo.Id) {
// try next share
continue
}
Expand Down
1 change: 1 addition & 0 deletions pkg/app/provider/demo/demo.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type provider struct {
}

func (p *provider) GetIFrame(ctx context.Context, resID *providerpb.Reference, token string) (string, error) {
// TODO @labkode @ishank011 should we use <storageid>!<nodeid>:<path> here? Or verify resource id is set and path is empty? or change signature to use a ResourceID directly?
msg := fmt.Sprintf("<iframe src=%s/open/%s?access-token=%s />", p.iframeUIProvider, resID.ResourceId.StorageId+":"+resID.ResourceId.OpaqueId, token)
return msg, nil
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/auth/scope/publicshare.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ func publicshareScope(scope *authpb.Scope, resource interface{}) (bool, error) {
}

func checkStorageRef(s *link.PublicShare, r *provider.Reference) bool {
// r: <id:<storage_id:$storageID node_id:$nodeID path:$path > >
// TODO @ishank011 con you explain how this is used?
// r: <resource_id:<storage_id:$storageID opaque_id:$opaqueID> path:$path > >
if r.ResourceId != nil && r.Path == "" { // path must be empty
return s.ResourceId.StorageId == r.ResourceId.StorageId && s.ResourceId.OpaqueId == r.ResourceId.OpaqueId
}
Expand Down
Loading

0 comments on commit bb23e7b

Please sign in to comment.