From 13541524c3001d6d3f7a0ed7690b51e8a3fd4b67 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Tue, 26 Jan 2021 19:36:35 -0800 Subject: [PATCH] Use server context --- router/router_server_backup.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/router/router_server_backup.go b/router/router_server_backup.go index cd34a0e..863b96d 100644 --- a/router/router_server_backup.go +++ b/router/router_server_backup.go @@ -1,7 +1,6 @@ package router import ( - "context" "net/http" "os" "strings" @@ -117,7 +116,10 @@ func postServerRestoreBackup(c *gin.Context) { // TODO: this will hang if there is an issue. We can't use c.Request.Context() (or really any) // since it will be canceled when the request is closed which happens quickly since we push // this into the background. - req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, data.DownloadUrl, nil) + // + // For now I'm just using the server context so at least the request is canceled if + // the server gets deleted. + req, err := http.NewRequestWithContext(s.Context(), http.MethodGet, data.DownloadUrl, nil) if err != nil { middleware.CaptureAndAbort(c, err) return