mirror of
				https://github.com/osmarks/mycorrhiza.git
				synced 2025-10-30 23:23:04 +00:00 
			
		
		
		
	Interwiki: Fix the bug that occurred with entries with no aliases
This commit is contained in:
		| @@ -45,13 +45,27 @@ func addEntry(wiki *Wiki) error { | |||||||
| 	defer mutex.Unlock() | 	defer mutex.Unlock() | ||||||
|  |  | ||||||
| 	var ( | 	var ( | ||||||
| 		names    = append(wiki.Aliases, wiki.Name) | 		// non-empty names only | ||||||
|  | 		names = func(names []string) []string { | ||||||
|  | 			var result []string | ||||||
|  | 			for _, name := range names { | ||||||
|  | 				if name != "" { | ||||||
|  | 					result = append(result, name) | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 			return result | ||||||
|  | 		}(append(wiki.Aliases, wiki.Name)) | ||||||
| 		ok, name = areNamesFree(names) | 		ok, name = areNamesFree(names) | ||||||
| 	) | 	) | ||||||
| 	if !ok { | 	if !ok { | ||||||
| 		log.Printf("There are multiple uses of the same name ‘%s’\n", name) | 		log.Printf("There are multiple uses of the same name ‘%s’\n", name) | ||||||
| 		return errors.New(name) | 		return errors.New(name) | ||||||
| 	} | 	} | ||||||
|  | 	if len(names) == 0 { | ||||||
|  | 		log.Println("No names passed for a new interwiki entry") | ||||||
|  | 		// There is something clearly wrong with error-returning in this function. | ||||||
|  | 		return errors.New("") | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	listOfEntries = append(listOfEntries, wiki) | 	listOfEntries = append(listOfEntries, wiki) | ||||||
| 	for _, name := range names { | 	for _, name := range names { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Timur Ismagilov
					Timur Ismagilov