mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-27 04:43:59 +01:00
Fix DeleteCollaboration
transaction behaviour (#28886)
The method can't be called with an outer transaction because if the user is not a collaborator the outer transaction will be rolled back even if the inner transaction uses the no-error path. `has == 0` leads to `return nil` which cancels the transaction. A standalone call of this method does nothing but if used with an outer transaction, that will be canceled.
This commit is contained in:
parent
23efd9d278
commit
8e9b6817bc
1 changed files with 5 additions and 2 deletions
|
@ -26,9 +26,12 @@ func DeleteCollaboration(ctx context.Context, repo *repo_model.Repository, uid i
|
|||
}
|
||||
defer committer.Close()
|
||||
|
||||
if has, err := db.GetEngine(ctx).Delete(collaboration); err != nil || has == 0 {
|
||||
if has, err := db.GetEngine(ctx).Delete(collaboration); err != nil {
|
||||
return err
|
||||
} else if err = access_model.RecalculateAccesses(ctx, repo); err != nil {
|
||||
} else if has == 0 {
|
||||
return committer.Commit()
|
||||
}
|
||||
if err = access_model.RecalculateAccesses(ctx, repo); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue