Add support for deleting a backup
This commit is contained in:
parent
33875105b6
commit
1c235025b7
|
@ -49,7 +49,6 @@ func Configure() *gin.Engine {
|
|||
server.POST("/commands", postServerCommands)
|
||||
server.POST("/install", postServerInstall)
|
||||
server.POST("/reinstall", postServerReinstall)
|
||||
server.POST("/backup", postServerBackup)
|
||||
|
||||
// This archive request causes the archive to start being created
|
||||
// this should only be triggered by the panel.
|
||||
|
@ -65,6 +64,12 @@ func Configure() *gin.Engine {
|
|||
files.POST("/create-directory", postServerCreateDirectory)
|
||||
files.POST("/delete", postServerDeleteFile)
|
||||
}
|
||||
|
||||
backup := server.Group("/backup")
|
||||
{
|
||||
backup.POST("", postServerBackup)
|
||||
backup.DELETE("/:backup", deleteServerBackup)
|
||||
}
|
||||
}
|
||||
|
||||
return router
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"github.com/pterodactyl/wings/server"
|
||||
"go.uber.org/zap"
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Backs up a server.
|
||||
|
@ -25,3 +26,21 @@ func postServerBackup(c *gin.Context) {
|
|||
|
||||
c.Status(http.StatusAccepted)
|
||||
}
|
||||
|
||||
// Deletes a local backup of a server.
|
||||
func deleteServerBackup(c *gin.Context) {
|
||||
s := GetServer(c.Param("server"))
|
||||
|
||||
p, _, err := s.LocateBackup(c.Param("backup"))
|
||||
if err != nil {
|
||||
TrackedServerError(err, s).AbortWithServerError(c)
|
||||
return
|
||||
}
|
||||
|
||||
if err := os.Remove(p); err != nil {
|
||||
TrackedServerError(err, s).AbortWithServerError(c)
|
||||
return
|
||||
}
|
||||
|
||||
c.Status(http.StatusNoContent)
|
||||
}
|
Loading…
Reference in New Issue
Block a user