@@ -39,6 +39,7 @@ type gRPCAppendBidiWriteBufferSender struct {
39
39
objectChecksums * storagepb.ObjectChecksums
40
40
41
41
forceFirstMessage bool
42
+ progress func (int64 )
42
43
flushOffset int64
43
44
44
45
// Fields used to report responses from the receive side of the stream
@@ -62,6 +63,7 @@ func (w *gRPCWriter) newGRPCAppendBidiWriteBufferSender() (*gRPCAppendBidiWriteB
62
63
},
63
64
objectChecksums : toProtoChecksums (w .sendCRC32C , w .attrs ),
64
65
forceFirstMessage : true ,
66
+ progress : w .progress ,
65
67
}
66
68
return s , nil
67
69
}
@@ -246,26 +248,35 @@ func (s *gRPCAppendBidiWriteBufferSender) sendOnConnectedStream(buf []byte, offs
246
248
if s .recvErr != io .EOF {
247
249
return nil , s .recvErr
248
250
}
251
+ if obj .GetSize () > s .flushOffset {
252
+ s .flushOffset = obj .GetSize ()
253
+ s .progress (s .flushOffset )
254
+ }
249
255
return
250
256
}
251
257
252
258
if flush {
253
259
// We don't necessarily expect multiple responses for a single flush, but
254
260
// this allows the server to send multiple responses if it wants to.
255
- for s .flushOffset < offset + int64 (len (buf )) {
261
+ flushOffset := s .flushOffset
262
+ for flushOffset < offset + int64 (len (buf )) {
256
263
resp , ok := <- s .recvs
257
264
if ! ok {
258
265
return nil , s .recvErr
259
266
}
260
267
pSize := resp .GetPersistedSize ()
261
268
rSize := resp .GetResource ().GetSize ()
262
- if s . flushOffset < pSize {
263
- s . flushOffset = pSize
269
+ if flushOffset < pSize {
270
+ flushOffset = pSize
264
271
}
265
- if s . flushOffset < rSize {
266
- s . flushOffset = rSize
272
+ if flushOffset < rSize {
273
+ flushOffset = rSize
267
274
}
268
275
}
276
+ if s .flushOffset < flushOffset {
277
+ s .flushOffset = flushOffset
278
+ s .progress (s .flushOffset )
279
+ }
269
280
}
270
281
271
282
return
0 commit comments