diff --git a/zipserver/slurp_handler.go b/zipserver/slurp_handler.go index 72f8080..8969715 100644 --- a/zipserver/slurp_handler.go +++ b/zipserver/slurp_handler.go @@ -12,6 +12,8 @@ import ( "time" ) +var slurpLockTable = NewLockTable() + func slurpHandler(w http.ResponseWriter, r *http.Request) error { ctx, cancel := context.WithTimeout(r.Context(), time.Duration(globalConfig.JobTimeout)) defer cancel() @@ -23,6 +25,11 @@ 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