summaryrefslogtreecommitdiff
path: root/system/admin/handlers.go
diff options
context:
space:
mode:
authorErwin Ticzon <eticzongh@gmail.com>2017-04-21 22:48:08 +1000
committerErwin Ticzon <eticzongh@gmail.com>2017-04-21 22:48:08 +1000
commit64f2a5bd9223826afe0869813385f6b925a13fb5 (patch)
tree89de4e310cc07b40d3bf8face14a638b92e6cbd2 /system/admin/handlers.go
parentd014fa69c51be5fa880d8ee5ae0ddbf4b2f5fd81 (diff)
add context cancellation to backup routines
Diffstat (limited to 'system/admin/handlers.go')
-rw-r--r--system/admin/handlers.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/system/admin/handlers.go b/system/admin/handlers.go
index 4f8ae83..4734ba0 100644
--- a/system/admin/handlers.go
+++ b/system/admin/handlers.go
@@ -195,9 +195,12 @@ func configHandler(res http.ResponseWriter, req *http.Request) {
}
func backupHandler(res http.ResponseWriter, req *http.Request) {
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
+
switch req.URL.Query().Get("source") {
case "system":
- err := db.Backup(res)
+ err := db.Backup(ctx, res)
if err != nil {
log.Println("Failed to run backup on system:", err)
res.WriteHeader(http.StatusInternalServerError)
@@ -205,7 +208,7 @@ func backupHandler(res http.ResponseWriter, req *http.Request) {
}
case "analytics":
- err := analytics.Backup(res)
+ err := analytics.Backup(ctx, res)
if err != nil {
log.Println("Failed to run backup on analytics:", err)
res.WriteHeader(http.StatusInternalServerError)
@@ -213,7 +216,7 @@ func backupHandler(res http.ResponseWriter, req *http.Request) {
}
case "uploads":
- err := upload.Backup(res)
+ err := upload.Backup(ctx, res)
if err != nil {
log.Println("Failed to run backup on uploads:", err)
res.WriteHeader(http.StatusInternalServerError)