mirror of
https://github.com/rclone/rclone.git
synced 2025-01-18 12:21:06 +01:00
swift: use Content-Length on uploads - fixes #125
This commit is contained in:
parent
b79dc01016
commit
95fd79faf9
@ -8,6 +8,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"path"
|
"path"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -558,6 +559,7 @@ func (o *FsObjectSwift) updateChunks(in io.Reader, headers swift.Headers, size i
|
|||||||
segmentsPath := fmt.Sprintf("%s%s/%s", o.swift.root, o.remote, uniquePrefix)
|
segmentsPath := fmt.Sprintf("%s%s/%s", o.swift.root, o.remote, uniquePrefix)
|
||||||
for left > 0 {
|
for left > 0 {
|
||||||
n := min(left, int64(chunkSize))
|
n := min(left, int64(chunkSize))
|
||||||
|
headers["Content-Length"] = strconv.FormatInt(n, 10) // set Content-Length as we know it
|
||||||
segmentReader := io.LimitReader(in, n)
|
segmentReader := io.LimitReader(in, n)
|
||||||
segmentPath := fmt.Sprintf("%s/%08d", segmentsPath, i)
|
segmentPath := fmt.Sprintf("%s/%08d", segmentsPath, i)
|
||||||
fs.Debug(o, "Uploading segment file %q into %q", segmentPath, o.swift.segmentsContainer)
|
fs.Debug(o, "Uploading segment file %q into %q", segmentPath, o.swift.segmentsContainer)
|
||||||
@ -570,6 +572,7 @@ func (o *FsObjectSwift) updateChunks(in io.Reader, headers swift.Headers, size i
|
|||||||
}
|
}
|
||||||
// Upload the manifest
|
// Upload the manifest
|
||||||
headers["X-Object-Manifest"] = fmt.Sprintf("%s/%s", o.swift.segmentsContainer, segmentsPath)
|
headers["X-Object-Manifest"] = fmt.Sprintf("%s/%s", o.swift.segmentsContainer, segmentsPath)
|
||||||
|
headers["Content-Length"] = "0" // set Content-Length as we know it
|
||||||
emptyReader := bytes.NewReader(nil)
|
emptyReader := bytes.NewReader(nil)
|
||||||
manifestName := o.swift.root + o.remote
|
manifestName := o.swift.root + o.remote
|
||||||
_, err = o.swift.c.ObjectPut(o.swift.container, manifestName, emptyReader, true, "", "", headers)
|
_, err = o.swift.c.ObjectPut(o.swift.container, manifestName, emptyReader, true, "", "", headers)
|
||||||
@ -597,8 +600,8 @@ func (o *FsObjectSwift) Update(in io.Reader, modTime time.Time, size int64) erro
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
headers["X-Object-Manifest"] = "" // remove manifest
|
headers["Content-Length"] = strconv.FormatInt(size, 10) // set Content-Length as we know it
|
||||||
_, err := o.swift.c.ObjectPut(o.swift.container, o.swift.root+o.remote, in, true, "", "", m.ObjectHeaders())
|
_, err := o.swift.c.ObjectPut(o.swift.container, o.swift.root+o.remote, in, true, "", "", headers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user