Skip to content

Commit

Permalink
make shares ids uniform with latest changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gmgigi96 committed Feb 14, 2024
1 parent 32c4e11 commit ec5211e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
8 changes: 2 additions & 6 deletions internal/http/services/owncloud/ocgraph/drives.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ package ocgraph

import (
"context"
"encoding/base32"
"encoding/json"
"fmt"
"net/http"
Expand All @@ -42,7 +41,6 @@ import (
"github.com/cs3org/reva/pkg/rhttp/router"
"github.com/cs3org/reva/pkg/spaces"
"github.com/cs3org/reva/pkg/utils/list"
"github.com/cs3org/reva/pkg/utils/resourceid"
libregraph "github.com/owncloud/libre-graph-api-go"
"github.com/pkg/errors"
)
Expand Down Expand Up @@ -181,8 +179,6 @@ func convertShareToSpace(ctx context.Context, gw gateway.GatewayAPIClient, share
}

// the prefix of the remote_item.id and rootid
idPrefix := base32.StdEncoding.EncodeToString([]byte(stat.Info.Path))
resourceIdEnc := base32.StdEncoding.EncodeToString([]byte(resourceid.OwnCloudResourceIDWrap(stat.Info.Id)))

space := &libregraph.Drive{
Id: libregraph.PtrString(fmt.Sprintf("%s$%s!%s", shareJailID, shareJailID, share.Id.OpaqueId)),
Expand All @@ -197,13 +193,13 @@ func convertShareToSpace(ctx context.Context, gw gateway.GatewayAPIClient, share
Folder: &libregraph.Folder{},
// The Id must correspond to the id in the OCS response, for the time being
// It is in the form <something>!<something-else>
Id: libregraph.PtrString(fmt.Sprintf("%s!%s", idPrefix, resourceIdEnc)),
Id: libregraph.PtrString(spaces.EncodeResourceID(stat.Info.Id)),
LastModifiedDateTime: libregraph.PtrTime(time.Unix(int64(stat.Info.Mtime.Seconds), int64(stat.Info.Mtime.Nanos))),
Name: libregraph.PtrString(filepath.Base(stat.Info.Path)),
Path: libregraph.PtrString("/"),
// RootId must have the same token before ! as Id
// the second part for the time being is not important
RootId: libregraph.PtrString(fmt.Sprintf("%s!wrong_root_id", idPrefix)),
RootId: libregraph.PtrString(fmt.Sprintf("%s!wrong_root_id", spaces.EncodeSpaceID(stat.Info.Id.StorageId, stat.Info.Id.SpaceId))),
Size: libregraph.PtrInt64(int64(stat.Info.Size)),
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ package shares
import (
"bytes"
"context"
"encoding/base32"
"encoding/json"
"fmt"
"mime"
Expand Down Expand Up @@ -49,6 +48,7 @@ import (
"github.com/cs3org/reva/internal/http/services/owncloud/ocs/conversions"
"github.com/cs3org/reva/internal/http/services/owncloud/ocs/response"
"github.com/cs3org/reva/pkg/appctx"
"github.com/cs3org/reva/pkg/spaces"

"github.com/cs3org/reva/pkg/notification"
"github.com/cs3org/reva/pkg/notification/notificationhelper"
Expand Down Expand Up @@ -1147,8 +1147,7 @@ func (h *Handler) addFileInfo(ctx context.Context, s *conversions.ShareData, inf
s.MimeType = parsedMt
// TODO STime: &types.Timestamp{Seconds: info.Mtime.Seconds, Nanos: info.Mtime.Nanos},
// TODO Storage: int
itemID := base32.StdEncoding.EncodeToString([]byte(info.Path))
itemID += "!" + base32.StdEncoding.EncodeToString([]byte(resourceid.OwnCloudResourceIDWrap(info.Id)))
itemID := spaces.EncodeResourceID(info.Id)

s.ItemSource = itemID
s.FileSource = s.ItemSource
Expand Down

0 comments on commit ec5211e

Please sign in to comment.