mirror of
				https://codeberg.org/forgejo/forgejo.git
				synced 2025-10-30 22:11:07 +00:00 
			
		
		
		
	In MirrorRepositoryList.loadAttributes there is some code to load the Mirror entries from the database. This assumes that every Repository which has IsMirror set has a Mirror associated in the DB. This association is incorrect in the case of Mirror repository under creation when there is no Mirror entry in the DB until completion. Unfortunately LoadAttributes makes this incorrect assumption and presumes that a Mirror will always be loaded. This then causes a panic. This PR simply double checks if there a Mirror before attempting to link back to its Repo. Unfortunately it should be expected that there may be other cases where this incorrect assumption causes further problems. Fix #20804 Signed-off-by: Andrew Thornton <art27@cantab.net> Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: zeripath <art27@cantab.net>
This commit is contained in:
		
					parent
					
						
							
								7a9b01a2dd
							
						
					
				
			
			
				commit
				
					
						c40c753613
					
				
			
		
					 1 changed files with 3 additions and 1 deletions
				
			
		|  | @ -153,8 +153,10 @@ func (repos MirrorRepositoryList) loadAttributes(ctx context.Context) error { | ||||||
| 	} | 	} | ||||||
| 	for i := range repos { | 	for i := range repos { | ||||||
| 		repos[i].Mirror = set[repos[i].ID] | 		repos[i].Mirror = set[repos[i].ID] | ||||||
|  | 		if repos[i].Mirror != nil { | ||||||
| 			repos[i].Mirror.Repo = repos[i] | 			repos[i].Mirror.Repo = repos[i] | ||||||
| 		} | 		} | ||||||
|  | 	} | ||||||
| 	return nil | 	return nil | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue