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

Remote: handle early return of compressed blobs uploads #14870

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Shreya Bhattarai <shreyax@google.com>
Kevin Bierhoff <kmb@google.com>
Klaas Boesche <klaasb@google.com>
Phil Bordelon <sunfall@google.com>
Mostyn Bramley-Moore <mostyn@antipode.se>
Jon Brandvein <brandjon@google.com>
Volker Braun <vbraun.name@gmail.com>
Thomas Broyer <t.broyer@ltgt.net>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,14 +323,34 @@ ListenableFuture<Void> start() {
// level/algorithm, so we cannot know the expected committed offset
long committedSize = committedOffset.get();
long expected = chunker.getOffset();
if (!chunker.hasNext() && committedSize != expected) {

if (committedSize == expected) {
// Both compressed and uncompressed uploads can succeed
// with this result.
return immediateVoidFuture();
}

if (chunker.isCompressed()) {
if (committedSize == -1) {
// Returned early, blob already available.
return immediateVoidFuture();
}

String message =
format(
"write incomplete: committed_size %d for %d total",
"compressed write incomplete: committed_size %d is neither -1 nor total %d",
committedSize, expected);
return Futures.immediateFailedFuture(new IOException(message));
}

// Uncompressed upload failed.
String message =
format(
"write incomplete: committed_size %d for %d total",
committedSize, expected);
return Futures.immediateFailedFuture(new IOException(message));
}

return immediateVoidFuture();
},
MoreExecutors.directExecutor());
Expand Down