Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update S3 flush to not have last part greater than defined chunkSize #4327

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 4 additions & 7 deletions registry/storage/driver/s3-aws/s3.go
Expand Up @@ -1612,13 +1612,6 @@ func (w *writer) flush() error {
}

buf := bytes.NewBuffer(w.ready.data)
if w.pending.Len() > 0 && w.pending.Len() < int(w.driver.ChunkSize) {
if _, err := buf.Write(w.pending.data); err != nil {
return err
}
w.pending.Clear()
}

partSize := buf.Len()
partNumber := aws.Int64(int64(len(w.parts) + 1))

Expand All @@ -1643,5 +1636,9 @@ func (w *writer) flush() error {
w.ready.Clear()
w.ready, w.pending = w.pending, w.ready

// In case we have more data in the pending buffer (now ready), we need to flush it
if w.ready.Len() > 0 {
return w.flush()
}
return nil
}