feat: enhance restore functionality with nginx restart and countdown dialog

This commit is contained in:
Jacky 2025-03-30 14:02:53 +00:00
parent 4c2487580e
commit 0ca9d84d10
No known key found for this signature in database
GPG key ID: 215C21B10DF38B4D
19 changed files with 768 additions and 641 deletions

View file

@ -9,10 +9,10 @@ import (
"time"
"github.com/0xJacky/Nginx-UI/internal/backup"
"github.com/0xJacky/Nginx-UI/internal/nginx"
"github.com/gin-gonic/gin"
"github.com/jpillora/overseer"
"github.com/uozi-tech/cosy"
"github.com/uozi-tech/cosy/logger"
)
// RestoreResponse contains the response data for restore operation
@ -29,10 +29,6 @@ func RestoreBackup(c *gin.Context) {
restoreNginxUI := c.PostForm("restore_nginx_ui") == "true"
verifyHash := c.PostForm("verify_hash") == "true"
securityToken := c.PostForm("security_token") // Get concatenated key and IV
logger.Debug("restoreNginx", restoreNginx)
logger.Debug("restoreNginxUI", restoreNginxUI)
logger.Debug("verifyHash", verifyHash)
logger.Debug("securityToken", securityToken)
// Get backup file
backupFile, err := c.FormFile("backup_file")
if err != nil {
@ -40,8 +36,6 @@ func RestoreBackup(c *gin.Context) {
return
}
logger.Debug("backupFile", backupFile.Size)
// Validate security token
if securityToken == "" {
cosy.ErrHandler(c, backup.ErrInvalidSecurityToken)
@ -118,6 +112,13 @@ func RestoreBackup(c *gin.Context) {
defer os.RemoveAll(restoreDir)
}
if restoreNginx {
go func() {
time.Sleep(2 * time.Second)
nginx.Restart()
}()
}
if restoreNginxUI {
go func() {
time.Sleep(2 * time.Second)