Skip to content

Commit 9ca8e01

Browse files
authored
fix(storage): Current object generation takeover. (#12383)
Correct handling when the caller specifies takeover for the current object generation. The previous behavior was inconsistent: it opened a writer when the user specified: ``` c.Bucket(b).Object(o).Generation(0).NewWriterFromAppendableObject(...) ``` But in the internal writer code would only perform takeovers for generations greater than 0.
1 parent d044e6f commit 9ca8e01

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

storage/grpc_writer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func (c *grpcStorageClient) OpenWriter(params *openWriterParams, opts ...storage
114114

115115
// If we are taking over an appendable object, send the first message here
116116
// to get the append offset.
117-
if params.appendGen > 0 {
117+
if params.append && params.appendGen >= 0 {
118118
// Create the buffer sender. This opens a stream and blocks until we
119119
// get a response that tells us what offset to write from.
120120
wbs, err := gw.newGRPCAppendTakeoverWriteBufferSender(params.ctx)
@@ -223,7 +223,7 @@ func newGRPCWriter(c *grpcStorageClient, s *settings, params *openWriterParams,
223223
Appendable: proto.Bool(params.append),
224224
}
225225
var appendSpec *storagepb.AppendObjectSpec
226-
if params.appendGen > 0 {
226+
if params.append && params.appendGen >= 0 {
227227
appendSpec = &storagepb.AppendObjectSpec{
228228
Bucket: bucketResourceName(globalProjectAlias, params.bucket),
229229
Object: params.attrs.Name,

0 commit comments

Comments
 (0)