♻️ Refactored site config synchronization

This commit is contained in:
2023-12-12 20:52:57 +08:00
parent 4dc2729024
commit 6905c60d82
2 changed files with 8 additions and 26 deletions

View File

@@ -30,19 +30,16 @@ func doSyncSite(c *fiber.Ctx) error {
defer file.Close()
}
pushed := false
sign.App.Sites = lo.Map(sign.App.Sites, func(item *sign.SiteConfig, idx int) *sign.SiteConfig {
if item.ID == id {
pushed = true
return &req
} else {
return item
if site, ok := lo.Find(sign.App.Sites, func(item *sign.SiteConfig) bool {
return item.ID == id
}); ok {
for _, process := range site.Processes {
process.StopProcess()
}
})
if !pushed {
sign.App.Sites = append(sign.App.Sites, &req)
}
// Reload
sign.ReadInConfig(viper.GetString("paths.configs"))
return c.SendStatus(fiber.StatusOK)
}