mirror of
https://github.com/rclone/rclone.git
synced 2025-01-09 15:58:28 +01:00
Merge pull request #4608 from ivandeex/pr-chunker-crypt
chunker: fix upload over crypt (fixes #4570)
This commit is contained in:
parent
41ccf01f29
commit
9a9a134188
@ -958,6 +958,8 @@ func (f *Fs) put(ctx context.Context, in io.Reader, src fs.ObjectInfo, remote st
|
|||||||
}
|
}
|
||||||
info := f.wrapInfo(src, chunkRemote, size)
|
info := f.wrapInfo(src, chunkRemote, size)
|
||||||
|
|
||||||
|
// Refill chunkLimit and let basePut repeatedly call chunkingReader.Read()
|
||||||
|
c.chunkLimit = c.chunkSize
|
||||||
// TODO: handle range/limit options
|
// TODO: handle range/limit options
|
||||||
chunk, errChunk := basePut(ctx, wrapIn, info, options...)
|
chunk, errChunk := basePut(ctx, wrapIn, info, options...)
|
||||||
if errChunk != nil {
|
if errChunk != nil {
|
||||||
@ -1166,10 +1168,14 @@ func (c *chunkingReader) updateHashes() {
|
|||||||
func (c *chunkingReader) Read(buf []byte) (bytesRead int, err error) {
|
func (c *chunkingReader) Read(buf []byte) (bytesRead int, err error) {
|
||||||
if c.chunkLimit <= 0 {
|
if c.chunkLimit <= 0 {
|
||||||
// Chunk complete - switch to next one.
|
// Chunk complete - switch to next one.
|
||||||
|
// Note #1:
|
||||||
// We might not get here because some remotes (eg. box multi-uploader)
|
// We might not get here because some remotes (eg. box multi-uploader)
|
||||||
// read the specified size exactly and skip the concluding EOF Read.
|
// read the specified size exactly and skip the concluding EOF Read.
|
||||||
// Then a check in the put loop will kick in.
|
// Then a check in the put loop will kick in.
|
||||||
c.chunkLimit = c.chunkSize
|
// Note #2:
|
||||||
|
// The crypt backend after receiving EOF here will call Read again
|
||||||
|
// and we must insist on returning EOF, so we postpone refilling
|
||||||
|
// chunkLimit to the main loop.
|
||||||
return 0, io.EOF
|
return 0, io.EOF
|
||||||
}
|
}
|
||||||
if int64(len(buf)) > c.chunkLimit {
|
if int64(len(buf)) > c.chunkLimit {
|
||||||
|
@ -71,6 +71,10 @@ backends:
|
|||||||
remote: "TestChunkerChunk50bSHA1HashS3:"
|
remote: "TestChunkerChunk50bSHA1HashS3:"
|
||||||
fastlist: true
|
fastlist: true
|
||||||
maxfile: 1k
|
maxfile: 1k
|
||||||
|
- backend: "chunker"
|
||||||
|
remote: "TestChunkerOverCrypt:"
|
||||||
|
fastlist: true
|
||||||
|
maxfile: 6k
|
||||||
- backend: "chunker"
|
- backend: "chunker"
|
||||||
remote: "TestChunkerChunk50bMD5QuickS3:"
|
remote: "TestChunkerChunk50bMD5QuickS3:"
|
||||||
fastlist: true
|
fastlist: true
|
||||||
|
Loading…
Reference in New Issue
Block a user