From e8a16a63430629d0114c89cf24e5c883df9af082 Mon Sep 17 00:00:00 2001 From: leaf corcoran Date: Thu, 14 Nov 2024 09:37:30 -0800 Subject: [PATCH] woops, move this to process function --- zipserver/slurp_handler.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/zipserver/slurp_handler.go b/zipserver/slurp_handler.go index 8969715..875b501 100644 --- a/zipserver/slurp_handler.go +++ b/zipserver/slurp_handler.go @@ -25,11 +25,6 @@ func slurpHandler(w http.ResponseWriter, r *http.Request) error { return err } - if !slurpLockTable.tryLockKey(key) { - return fmt.Errorf("Key is currently being processed: %s", key) - } - defer slurpLockTable.releaseKey(key) - slurpURL, err := getParam(params, "url") if err != nil { return err @@ -49,6 +44,11 @@ func slurpHandler(w http.ResponseWriter, r *http.Request) error { } process := func(ctx context.Context) error { + if !slurpLockTable.tryLockKey(key) { + return fmt.Errorf("Key is currently being processed: %s", key) + } + defer slurpLockTable.releaseKey(key) + getCtx, cancel := context.WithTimeout(ctx, time.Duration(globalConfig.FileGetTimeout)) defer cancel()