mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 02:15:48 +02:00
feat: enhance restore functionality with nginx restart and countdown dialog
This commit is contained in:
parent
4c2487580e
commit
0ca9d84d10
19 changed files with 768 additions and 641 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue