mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-11-04 08:34:30 +01:00 
			
		
		
		
	Safely handle map deletions in refreshAccesses to avoid iteration issues
This commit is contained in:
		
							parent
							
								
									5901bd75ca
								
							
						
					
					
						commit
						91bd7c536f
					
				@ -105,8 +105,10 @@ func refreshAccesses(ctx context.Context, repo *repo_model.Repository, accessMap
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	newAccesses := make([]Access, 0, len(accessMap))
 | 
			
		||||
	keysToDelete := []int64{}
 | 
			
		||||
	for userID, ua := range accessMap {
 | 
			
		||||
		if ua.Mode < minMode && !ua.User.IsRestricted {
 | 
			
		||||
			keysToDelete = append(keysToDelete, userID)
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -116,6 +118,9 @@ func refreshAccesses(ctx context.Context, repo *repo_model.Repository, accessMap
 | 
			
		||||
			Mode:   ua.Mode,
 | 
			
		||||
		})
 | 
			
		||||
	}
 | 
			
		||||
	for _, uid := range keysToDelete {
 | 
			
		||||
		delete(accessMap, uid)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Delete old accesses and insert new ones for repository.
 | 
			
		||||
	if _, err = db.DeleteByBean(ctx, &Access{RepoID: repo.ID}); err != nil {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user