Add support for deleting a backup

This commit is contained in:
Dane Everitt
2020-04-09 22:07:48 -07:00
parent 33875105b6
commit 1c235025b7
2 changed files with 25 additions and 1 deletions

View File

@@ -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)
}