|
|
@ -85,8 +85,8 @@ func updateUserAccess(accessMap map[int64]*userAccess, user *user_model.User, mo |
|
|
|
// FIXME: do cross-comparison so reduce deletions and additions to the minimum?
|
|
|
|
// FIXME: do cross-comparison so reduce deletions and additions to the minimum?
|
|
|
|
func refreshAccesses(ctx context.Context, repo *repo_model.Repository, accessMap map[int64]*userAccess) (err error) { |
|
|
|
func refreshAccesses(ctx context.Context, repo *repo_model.Repository, accessMap map[int64]*userAccess) (err error) { |
|
|
|
minMode := perm.AccessModeRead |
|
|
|
minMode := perm.AccessModeRead |
|
|
|
if err := repo.GetOwner(ctx); err != nil { |
|
|
|
if err := repo.LoadOwner(ctx); err != nil { |
|
|
|
return fmt.Errorf("GetOwner: %w", err) |
|
|
|
return fmt.Errorf("LoadOwner: %w", err) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// If the repo isn't private and isn't owned by a organization,
|
|
|
|
// If the repo isn't private and isn't owned by a organization,
|
|
|
@ -143,7 +143,7 @@ func refreshCollaboratorAccesses(ctx context.Context, repoID int64, accessMap ma |
|
|
|
func RecalculateTeamAccesses(ctx context.Context, repo *repo_model.Repository, ignTeamID int64) (err error) { |
|
|
|
func RecalculateTeamAccesses(ctx context.Context, repo *repo_model.Repository, ignTeamID int64) (err error) { |
|
|
|
accessMap := make(map[int64]*userAccess, 20) |
|
|
|
accessMap := make(map[int64]*userAccess, 20) |
|
|
|
|
|
|
|
|
|
|
|
if err = repo.GetOwner(ctx); err != nil { |
|
|
|
if err = repo.LoadOwner(ctx); err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} else if !repo.Owner.IsOrganization() { |
|
|
|
} else if !repo.Owner.IsOrganization() { |
|
|
|
return fmt.Errorf("owner is not an organization: %d", repo.OwnerID) |
|
|
|
return fmt.Errorf("owner is not an organization: %d", repo.OwnerID) |
|
|
@ -199,7 +199,7 @@ func RecalculateUserAccess(ctx context.Context, repo *repo_model.Repository, uid |
|
|
|
accessMode = collaborator.Mode |
|
|
|
accessMode = collaborator.Mode |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if err = repo.GetOwner(ctx); err != nil { |
|
|
|
if err = repo.LoadOwner(ctx); err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} else if repo.Owner.IsOrganization() { |
|
|
|
} else if repo.Owner.IsOrganization() { |
|
|
|
var teams []organization.Team |
|
|
|
var teams []organization.Team |
|
|
|