Skip to content
Merged
Changes from 2 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
13 changes: 8 additions & 5 deletions src/gcp/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,13 @@ impl GoogleCloudStorageClient {
extensions,
} = opts;

let builder = self
.request(Method::PUT, path)
let builder = self.request(Method::PUT, path);
let builder = if payload.content_length() == 0 {
builder.header(&CONTENT_LENGTH, "0")
} else {
builder
};
let builder = builder
Copy link
Contributor

@tustvold tustvold Mar 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is unnecessary, with_payload already handles this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah got it, I just reverted this change.

.with_payload(payload)
.with_attributes(attributes)
.with_extensions(extensions);
Expand Down Expand Up @@ -516,9 +521,7 @@ impl GoogleCloudStorageClient {
if completed_parts.is_empty() {
// GCS doesn't allow empty multipart uploads
let result = self
.request(Method::PUT, path)
.idempotent(true)
.do_put()
.put(path, PutPayload::new(), Default::default())
.await?;
self.multipart_cleanup(path, multipart_id).await?;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tustvold I was also trying to think about how to make this more obvious. Perhaps the following structure is more clear? The comment clarifies that we're falling back to a non-multipart upload. Also moving the PUT after the cleanup makes it clear that the cleanup is not affecting the PUT. What do you think?

            // GCS doesn't allow empty multipart uploads, so fallback to regular upload.
            self.multipart_cleanup(path, multipart_id).await?;
            let result = self
                .put(path, PutPayload::new(), Default::default())
                .await?;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel strongly either way

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I made the change.

return Ok(result);
Expand Down