1
0
mirror of https://github.com/rclone/rclone.git synced 2025-12-16 00:04:40 +00:00

b2: Make sure each upload has at least one upload slot - fixes #731

This commit is contained in:
Nick Craig-Wood
2016-10-10 15:57:56 +01:00
parent 0238558a4b
commit 544ca6035a
2 changed files with 73 additions and 5 deletions

View File

@@ -240,6 +240,8 @@ func (up *largeUpload) Upload() error {
errs := make(chan error, 1)
var wg sync.WaitGroup
var err error
uploadCounter := up.f.newMultipartUploadCounter()
defer uploadCounter.finished()
fs.AccountByPart(up.o) // Cancel whole file accounting before reading
outer:
for part := int64(1); part <= up.parts; part++ {
@@ -264,10 +266,10 @@ outer:
// Transfer the chunk
// Get upload Token
up.f.getUploadToken()
token := uploadCounter.getMultipartUploadToken()
wg.Add(1)
go func(part int64, buf []byte) {
defer up.f.returnUploadToken()
go func(part int64, buf []byte, token bool) {
defer uploadCounter.returnMultipartUploadToken(token)
defer wg.Done()
err := up.transferChunk(part, buf)
if err != nil {
@@ -276,7 +278,7 @@ outer:
default:
}
}
}(part, buf)
}(part, buf, token)
remaining -= reqSize
}