Break out the backup functions of the daemon in prep for S3 support

This commit is contained in:
Dane Everitt
2020-04-13 22:01:07 -07:00
parent fd9487ea4d
commit 11035b561a
7 changed files with 260 additions and 227 deletions

View File

@@ -4,6 +4,7 @@ import (
"bufio"
"github.com/gin-gonic/gin"
"github.com/pterodactyl/wings/router/tokens"
"github.com/pterodactyl/wings/server/backup"
"net/http"
"os"
"strconv"
@@ -25,13 +26,20 @@ func getDownloadBackup(c *gin.Context) {
return
}
p, st, err := s.LocateBackup(token.BackupUuid)
b, st, err := backup.LocateLocal(token.BackupUuid)
if err != nil {
if os.IsNotExist(err) {
c.AbortWithStatusJSON(http.StatusNotFound, gin.H{
"error": "The requested backup was not found on this server.",
})
return
}
TrackedServerError(err, s).AbortWithServerError(c)
return
}
f, err := os.Open(p)
f, err := os.Open(b.Path())
if err != nil {
TrackedServerError(err, s).AbortWithServerError(c)
return