From 4526d5d197acaf6f338694364a2073069f639bc6 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Fri, 18 Dec 2020 23:38:09 +0100 Subject: [PATCH] swift: explicitly pass upload size to library This allows properly setting the content-length which could help the server-side to detect incomplete uploads. --- internal/backend/swift/swift.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/backend/swift/swift.go b/internal/backend/swift/swift.go index 488ccbd14..92b6567e3 100644 --- a/internal/backend/swift/swift.go +++ b/internal/backend/swift/swift.go @@ -6,6 +6,7 @@ import ( "io" "net/http" "path" + "strconv" "strings" "time" @@ -176,7 +177,9 @@ func (be *beSwift) Save(ctx context.Context, h restic.Handle, rd restic.RewindRe encoding := "binary/octet-stream" debug.Log("PutObject(%v, %v, %v)", be.container, objName, encoding) - _, err := be.conn.ObjectPut(be.container, objName, rd, true, "", encoding, nil) + hdr := swift.Headers{"Content-Length": strconv.FormatInt(rd.Length(), 10)} + _, err := be.conn.ObjectPut(be.container, objName, rd, true, "", encoding, hdr) + // swift does not return the upload length debug.Log("%v, err %#v", objName, err) return errors.Wrap(err, "client.PutObject")