Merge pull request #7336 from aduffeck/backport-jsoncs3-rebuild-fix

Do not reset received share state to pending if there is a state already
This commit is contained in:
Michael Barz
2023-09-25 14:24:59 +02:00
committed by GitHub
2 changed files with 18 additions and 6 deletions

View File

@@ -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

View File

@@ -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()