🎨 Improve callback functions
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				release-nightly / build-docker (push) Successful in 1m6s
				
					
					
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	release-nightly / build-docker (push) Successful in 1m6s
				This commit is contained in:
		| @@ -29,7 +29,6 @@ func doSyncSite(c *fiber.Ctx) error { | ||||
| 		file.Write(raw) | ||||
| 		defer file.Close() | ||||
| 	} | ||||
|  | ||||
| 	if site, ok := lo.Find(sign.App.Sites, func(item *sign.SiteConfig) bool { | ||||
| 		return item.ID == id | ||||
| 	}); ok { | ||||
| @@ -40,7 +39,7 @@ func doSyncSite(c *fiber.Ctx) error { | ||||
|  | ||||
| 	// Reload | ||||
| 	sign.ReadInConfig(viper.GetString("paths.configs")) | ||||
| 	sign.App.PreheatProcesses(func(total int, success int) {}) | ||||
| 	sign.App.PreheatProcesses() | ||||
|  | ||||
| 	return c.SendStatus(fiber.StatusOK) | ||||
| } | ||||
|   | ||||
| @@ -80,7 +80,7 @@ func (v *ProcessConfig) StopProcess() error { | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (v *RoadApp) PreheatProcesses(callback func(total int, success int)) { | ||||
| func (v *RoadApp) PreheatProcesses(callbacks ...func(total int, success int)) { | ||||
| 	var processes []*ProcessConfig | ||||
| 	for _, site := range v.Sites { | ||||
| 		for _, process := range site.Processes { | ||||
| @@ -97,5 +97,9 @@ func (v *RoadApp) PreheatProcesses(callback func(total int, success int)) { | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	callback(len(processes), success) | ||||
| 	if len(callbacks) > 0 { | ||||
| 		for _, callback := range callbacks { | ||||
| 			callback(len(processes), success) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user