persistLocked saves the current in-memory config to disk. It expects the caller to hold h.mu.
(c *gin.Context)
| 406 | // persistLocked saves the current in-memory config to disk. |
| 407 | // It expects the caller to hold h.mu. |
| 408 | func (h *Handler) persistLocked(c *gin.Context) bool { |
| 409 | // Preserve comments when writing |
| 410 | if err := config.SaveConfigPreserveComments(h.configFilePath, h.cfg); err != nil { |
| 411 | c.JSON(http.StatusInternalServerError, gin.H{"error": fmt.Sprintf("failed to save config: %v", err)}) |
| 412 | return false |
| 413 | } |
| 414 | snapshot := h.reloadSnapshotConfigLocked() |
| 415 | c.JSON(http.StatusOK, gin.H{"status": "ok"}) |
| 416 | var reqCtx context.Context |
| 417 | if c != nil && c.Request != nil { |
| 418 | reqCtx = c.Request.Context() |
| 419 | } |
| 420 | h.reloadConfigAfterManagementSaveAsync(reqCtx, snapshot) |
| 421 | return true |
| 422 | } |
| 423 | |
| 424 | // Helper methods for simple types |
| 425 | func (h *Handler) updateBoolField(c *gin.Context, set func(bool)) { |
no test coverage detected