diff --git a/changelog/unreleased/do-not-reset-received-share-state.md b/changelog/unreleased/do-not-reset-received-share-state.md new file mode 100644 index 00000000000..d05cbbca142 --- /dev/null +++ b/changelog/unreleased/do-not-reset-received-share-state.md @@ -0,0 +1,6 @@ +Bugfix: Do not reset received share state to pending + +We fixed a problem where the states of received shares were reset to PENDING +in the "ocis migrate rebuild-jsoncs3-indexes" command + +https://github.com/owncloud/ocis/issues/7319 diff --git a/ocis/pkg/command/migrate.go b/ocis/pkg/command/migrate.go index a9bcde67415..7c16f207c3a 100644 --- a/ocis/pkg/command/migrate.go +++ b/ocis/pkg/command/migrate.go @@ -162,14 +162,20 @@ func RebuildJSONCS3Indexes(cfg *config.Config) *cli.Command { switch share.Grantee.Type { case provider.GranteeType_GRANTEE_TYPE_USER: userid := share.Grantee.GetUserId().GetOpaqueId() - rs := &collaboration.ReceivedShare{ - Share: share, - State: collaboration.ShareState_SHARE_STATE_PENDING, - } - err := mgr.UserReceivedStates.Add(ctx, userid, spaceId, rs) + existingState, err := mgr.UserReceivedStates.Get(ctx, userid, spaceId, share.Id.OpaqueId) if err != nil { - fmt.Printf(" adding share '%s' to the user cache failed! (%s)\n", share.Id.OpaqueId, err.Error()) + fmt.Printf(" retrieving current state of received share '%s' from the user cache failed! (%s)\n", share.Id.OpaqueId, err.Error()) errorsOccured = true + } else if existingState == nil { + rs := &collaboration.ReceivedShare{ + Share: share, + State: collaboration.ShareState_SHARE_STATE_PENDING, + } + err := mgr.UserReceivedStates.Add(ctx, userid, spaceId, rs) + if err != nil { + fmt.Printf(" adding share '%s' to the user cache failed! (%s)\n", share.Id.OpaqueId, err.Error()) + errorsOccured = true + } } case provider.GranteeType_GRANTEE_TYPE_GROUP: groupid := share.Grantee.GetGroupId().GetOpaqueId()