10467: Abort S3 and release buffer if caller disconnects during S3 PUT request.
[arvados.git] / services / keepstore / pull_worker.go
index 2626d4bf68e1594f394ad4539f0f32a90fe00339..e42b6e4b89230cdbe4a40a99fc803044febe421c 100644 (file)
@@ -1,8 +1,8 @@
 package main
 
 import (
+       "context"
        "crypto/rand"
-       "errors"
        "fmt"
        "git.curoverse.com/arvados.git/sdk/go/keepclient"
        "io"
@@ -57,7 +57,7 @@ func PullItemAndProcess(pullRequest PullRequest, token string, keepClient *keepc
                return
        }
        if reader == nil {
-               return errors.New(fmt.Sprintf("No reader found for : %s", signedLocator))
+               return fmt.Errorf("No reader found for : %s", signedLocator)
        }
        defer reader.Close()
 
@@ -67,7 +67,7 @@ func PullItemAndProcess(pullRequest PullRequest, token string, keepClient *keepc
        }
 
        if (readContent == nil) || (int64(len(readContent)) != contentLen) {
-               return errors.New(fmt.Sprintf("Content not found for: %s", signedLocator))
+               return fmt.Errorf("Content not found for: %s", signedLocator)
        }
 
        err = PutContent(readContent, pullRequest.Locator)
@@ -95,6 +95,6 @@ func GenerateRandomAPIToken() string {
 
 // Put block
 var PutContent = func(content []byte, locator string) (err error) {
-       _, err = PutBlock(content, locator)
+       _, err = PutBlock(context.TODO(), content, locator)
        return
 }