summaryrefslogtreecommitdiff
path: root/system/admin/handlers.go
diff options
context:
space:
mode:
authorSteve Manuel <nilslice@gmail.com>2017-04-23 23:47:58 -0700
committerGitHub <noreply@github.com>2017-04-23 23:47:58 -0700
commit7092fb8979869f3c09b364d454d8d8081bb7c0bc (patch)
treea3ac23fb9c26b14b1fe864a74a190b2f7695490b /system/admin/handlers.go
parentd014fa69c51be5fa880d8ee5ae0ddbf4b2f5fd81 (diff)
parent9ef764c6be9239e61998de82f21a377d2c9306bb (diff)
Merge pull request #133 from ponzu-cms/ponzu-dev
[core] Add cancellation context to system backups
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)