Dane caused this monstrosity to occur.. Port over remaining transfer/archive code to gin, delete http.go

This commit is contained in:
Matthew Penner
2020-04-06 13:49:49 -06:00
parent 03311ecf03
commit 718b126baf
7 changed files with 106 additions and 167 deletions

View File

@@ -2,12 +2,9 @@ package router
import (
"github.com/gin-gonic/gin"
"github.com/pkg/errors"
"github.com/pterodactyl/wings/api"
"github.com/pterodactyl/wings/server"
"go.uber.org/zap"
"net/http"
"time"
)
// Backs up a server.
@@ -28,37 +25,3 @@ func postServerBackup(c *gin.Context) {
c.Status(http.StatusAccepted)
}
func getServerArchive(c *gin.Context) {
}
func postServerArchive(c *gin.Context) {
s := GetServer(c.Param("server"))
go func() {
start := time.Now()
if err := s.Archiver.Archive(); err != nil {
zap.S().Errorw("failed to get archive for server", zap.String("server", s.Uuid), zap.Error(err))
return
}
zap.S().Debugw("successfully created archive for server", zap.String("server", s.Uuid), zap.Duration("time", time.Now().Sub(start).Round(time.Microsecond)))
r := api.NewRequester()
rerr, err := r.SendArchiveStatus(s.Uuid, true)
if rerr != nil || err != nil {
if err != nil {
zap.S().Errorw("failed to notify panel with archive status", zap.String("server", s.Uuid), zap.Error(err))
return
}
zap.S().Errorw("panel returned an error when sending the archive status", zap.String("server", s.Uuid), zap.Error(errors.New(rerr.String())))
return
}
zap.S().Debugw("successfully notified panel about archive status", zap.String("server", s.Uuid))
}()
c.Status(http.StatusAccepted)
}