fix lock
This commit is contained in:
13
api.go
13
api.go
@@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
func ApiRun(c *gin.Context) {
|
||||
cfg.Run()
|
||||
cfg.Run(true)
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"message": "done",
|
||||
})
|
||||
@@ -118,7 +118,7 @@ func ApiRunApp(c *gin.Context) {
|
||||
}
|
||||
|
||||
func ApiSave(c *gin.Context) {
|
||||
if err := cfg.Save(); err != nil {
|
||||
if err := cfg.Save(true); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"message": "error",
|
||||
"error": err,
|
||||
@@ -131,7 +131,7 @@ func ApiSave(c *gin.Context) {
|
||||
}
|
||||
|
||||
func ApiConfig(c *gin.Context) {
|
||||
if b, err := cfg.Pretty(); err != nil {
|
||||
if b, err := cfg.Pretty(true); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"message": "error",
|
||||
"error": err,
|
||||
@@ -151,7 +151,7 @@ func ApiConfigApp(c *gin.Context) {
|
||||
for _, app := range cfg.Apps {
|
||||
if app.Name == name {
|
||||
found = true
|
||||
if b, err := app.Pretty(); err != nil {
|
||||
if b, err := app.Pretty(false); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"message": "error",
|
||||
"error": err,
|
||||
@@ -220,7 +220,7 @@ func ApiAppAdd(c *gin.Context) {
|
||||
cfg.Apps = append(cfg.Apps, app)
|
||||
|
||||
CfgUnlock()
|
||||
err := cfg.Save()
|
||||
err := cfg.Save(false)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"message": "error",
|
||||
@@ -262,8 +262,7 @@ func ApiAppDel(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
CfgUnlock()
|
||||
err := cfg.Save()
|
||||
err := cfg.Save(false)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"message": "error",
|
||||
|
||||
Reference in New Issue
Block a user