Skip to content

Commit

Permalink
Cleanup code (#3530)
Browse files Browse the repository at this point in the history
* Cleanup code

* run linter

* add changelog

* revert
  • Loading branch information
gmgigi96 authored Dec 7, 2022
1 parent 2c4e018 commit a701674
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 30 deletions.
1 change: 1 addition & 0 deletions changelog/unreleased/improve-ocmd-error-logs.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Enhancement: Improve error logging in ocmd flow

https://github.com/cs3org/reva/pull/3530
https://github.com/cs3org/reva/pull/3526
https://github.com/cs3org/reva/pull/3419
https://github.com/cs3org/reva/issues/3365
Expand Down
10 changes: 0 additions & 10 deletions pkg/ocm/share/manager/json/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (
ocm "github.com/cs3org/go-cs3apis/cs3/sharing/ocm/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
typespb "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
"github.com/cs3org/reva/pkg/appctx"
ctxpkg "github.com/cs3org/reva/pkg/ctx"
"github.com/cs3org/reva/pkg/errtypes"
"github.com/cs3org/reva/pkg/ocm/share"
Expand Down Expand Up @@ -265,15 +264,6 @@ func (m *mgr) Share(ctx context.Context, md *provider.ResourceId, g *ocm.ShareGr
protocol["name"] = "datatx"
}

log := appctx.GetLogger(ctx)
log.Info().Msg("pkg/ocm/share/manager/json calls sender.Send")
log.Info().Msgf("pkg/ocm/share/manager/json shareWith: %s", g.Grantee.GetUserId().OpaqueId)
log.Info().Msgf("pkg/ocm/share/manager/json name: %s", name)
log.Info().Msgf("pkg/ocm/share/manager/json providerId: %s", fmt.Sprintf("%s:%s", md.StorageId, md.OpaqueId))
log.Info().Msgf("pkg/ocm/share/manager/json owner: %s", userID.OpaqueId)
log.Info().Msgf("pkg/ocm/share/manager/json protocol: %s", protocol)
log.Info().Msgf("pkg/ocm/share/manager/json meshProvider: %s", userID.Idp)

requestBodyMap := map[string]interface{}{
"shareWith": g.Grantee.GetUserId().OpaqueId,
"name": name,
Expand Down
30 changes: 10 additions & 20 deletions pkg/ocm/share/manager/nextcloud/nextcloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,16 +362,6 @@ func (sm *Manager) Share(ctx context.Context, md *provider.ResourceId, g *ocm.Sh
}
}

log := appctx.GetLogger(ctx)
log.Info().Msg("pkg/ocm/share/manager/nextcloud calls sender.Send")
log.Info().Msgf("pkg/ocm/share/manager/nextcloud shareWith: %s", g.Grantee.GetUserId().OpaqueId)
log.Info().Msgf("pkg/ocm/share/manager/nextcloud name: %s", name)
log.Info().Msgf("pkg/ocm/share/manager/nextcloud providerId: %s", s.Id.OpaqueId)
log.Info().Msgf("pkg/ocm/share/manager/nextcloud owner: %s", userID.OpaqueId)
log.Info().Msgf("pkg/ocm/share/manager/nextcloud protocol: %s", protocol)
log.Info().Msgf("pkg/ocm/share/manager/nextcloud meshProvider: %s", userID.Idp)
log.Info().Msgf("Truncating name from %s to %s", name, name[5:])

// required:
// shareWith string Consumer specific identifier of the user or group the provider wants to share the resource with. This is known in advance. Please note that the consumer service endpoint is known in advance as well, so this is no part of the request body.
// name string Name of the resource (file or folder).
Expand Down Expand Up @@ -543,15 +533,15 @@ func (sm *Manager) ListReceivedShares(ctx context.Context) ([]*ocm.ReceivedShare
if err != nil {
return nil, err
}
var pointersBaseShare = make([]*ocm.Share, len(respArr))
var pointersReceivedShare = make([]*ocm.ReceivedShare, len(respArr))
for i := 0; i < len(respArr); i++ {
log.Info().Msgf("Unpacking share object %+v\n", respArr[i].Share)
altResultShare := respArr[i].Share

var pointersReceivedShare = make([]*ocm.ReceivedShare, 0, len(respArr))
for _, share := range respArr {
altResultShare := share.Share
log.Info().Msgf("Unpacking share object %+v\n", altResultShare)
if altResultShare == nil {
return nil, errors.New("received an unreadable share object from the EFSS backend")
}
pointersBaseShare[i] = &ocm.Share{
s := &ocm.Share{
Id: altResultShare.ID,
ResourceId: altResultShare.ResourceID,
Permissions: altResultShare.Permissions,
Expand All @@ -563,10 +553,10 @@ func (sm *Manager) ListReceivedShares(ctx context.Context) ([]*ocm.ReceivedShare
Ctime: altResultShare.Ctime,
Mtime: altResultShare.Mtime,
}
pointersReceivedShare[i] = &ocm.ReceivedShare{
Share: pointersBaseShare[i],
State: respArr[i].State,
}
pointersReceivedShare = append(pointersReceivedShare, &ocm.ReceivedShare{
Share: s,
State: share.State,
})
}
return pointersReceivedShare, err
}
Expand Down

0 comments on commit a701674

Please sign in to comment.