Skip to content

Commit a5cff60

Browse files
committed
minor fixes
1 parent 1e5a627 commit a5cff60

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

google-api-go-generator/gen.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2283,7 +2283,9 @@ func (meth *Method) generateCode() {
22832283
if meth.supportsMediaUpload() && meth.api.Name == "storage" {
22842284
comment = "Set auto checksum in case of a single chunk upload if enabled."
22852285
p("%s", asComment("", comment))
2286-
pn("if c.mediaInfo_ != nil {")
2286+
pn("if c.object != nil &&")
2287+
pn(" c.mediaInfo_ != nil &&")
2288+
pn(` c.mediaInfo_.UploadType() == "multipart" {`)
22872289
pn(" c.object.Crc32c = c.mediaInfo_.GetAutoChecksum()")
22882290
pn("}")
22892291
}

internal/gensupport/media.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,13 @@ func (mi *MediaInfo) UploadType() string {
198198
return "resumable"
199199
}
200200

201-
// GetAutoChecksum returns the computed auto checksum (if enabled)
202-
// for single-chunk resumable uploads.
201+
// GetAutoChecksum returns the computed auto checksum from buffer (if enabled).
202+
// Make sure whole data is written and read from the buffer before calling this
203+
// function to get correct checksum of the data.
203204
func (mi *MediaInfo) GetAutoChecksum() string {
204-
if mi.buffer.enableAutoChecksum &&
205-
mi.buffer != nil &&
206-
mi.singleChunk {
207-
return encodeUint32(mi.buffer.fullObjectChecksum + 1)
205+
if mi.buffer != nil &&
206+
mi.buffer.enableAutoChecksum {
207+
return encodeUint32(mi.buffer.fullObjectChecksum)
208208
}
209209
return ""
210210
}

storage/v1/storage-gen.go

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)