Skip to content

Commit

Permalink
backup toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
wangsongyan committed Oct 31, 2024
1 parent a45adf2 commit 9c0f9e5
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions controllers/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ func RestorePost(c *gin.Context) {
res["message"] = "fileName cannot be empty."
return
}

if cfg.Database.Dialect != "sqlite" {
res["message"] = "only support sqlite dialect"
return
}
if !cfg.Backup.Enabled || !cfg.Qiniu.Enabled {
res["message"] = "backup or quniu not enabled"
return
}

fileUrl = cfg.Qiniu.FileServer + fileName
resp, err = http.Get(fileUrl)
if err != nil {
Expand Down Expand Up @@ -84,6 +94,16 @@ func Backup() (err error) {
bodyBytes []byte
cfg = system.GetConfiguration()
)

if cfg.Database.Dialect != "sqlite" {
err = errors.New("only support sqlite dialect")
return
}
if !cfg.Backup.Enabled || !cfg.Qiniu.Enabled {
err = errors.New("backup or quniu not enabled")
return
}

u, err = url.Parse(cfg.Database.DSN)
if err != nil {
seelog.Debugf("parse dsn error:%v", err)
Expand Down

0 comments on commit 9c0f9e5

Please sign in to comment.