Update middleware logic

This commit is contained in:
Dane Everitt
2020-12-15 20:19:09 -08:00
parent 84c05efaa5
commit acd6dc62d0
10 changed files with 175 additions and 77 deletions

View File

@@ -15,7 +15,7 @@ import (
func getDownloadBackup(c *gin.Context) {
token := tokens.BackupPayload{}
if err := tokens.ParseToken([]byte(c.Query("token")), &token); err != nil {
TrackedError(err).AbortWithServerError(c)
TrackedError(err).Abort(c)
return
}
@@ -36,13 +36,13 @@ func getDownloadBackup(c *gin.Context) {
return
}
TrackedServerError(err, s).AbortWithServerError(c)
TrackedServerError(err, s).Abort(c)
return
}
f, err := os.Open(b.Path())
if err != nil {
TrackedServerError(err, s).AbortWithServerError(c)
TrackedServerError(err, s).Abort(c)
return
}
defer f.Close()
@@ -58,7 +58,7 @@ func getDownloadBackup(c *gin.Context) {
func getDownloadFile(c *gin.Context) {
token := tokens.FilePayload{}
if err := tokens.ParseToken([]byte(c.Query("token")), &token); err != nil {
TrackedError(err).AbortWithServerError(c)
TrackedError(err).Abort(c)
return
}
@@ -75,7 +75,7 @@ func getDownloadFile(c *gin.Context) {
// If there is an error or we're somehow trying to download a directory, just
// respond with the appropriate error.
if err != nil {
TrackedServerError(err, s).AbortWithServerError(c)
TrackedServerError(err, s).Abort(c)
return
} else if st.IsDir() {
c.AbortWithStatusJSON(http.StatusNotFound, gin.H{
@@ -86,7 +86,7 @@ func getDownloadFile(c *gin.Context) {
f, err := os.Open(p)
if err != nil {
TrackedServerError(err, s).AbortWithServerError(c)
TrackedServerError(err, s).Abort(c)
return
}