Permalink
Browse files

CSHARP-715: InsertBatch fails when large batch has to be split into s…

…maller sub batches.
  • Loading branch information...
rstam
rstam committed Mar 27, 2013
1 parent 072aad4 commit 7e7b57a33821da5cdf339c55f583761c58fdfa9d
Showing with 2 additions and 0 deletions.
  1. +2 −0 MongoDB.Driver/Communication/Messages/MongoInsertMessage.cs
@@ -60,6 +60,7 @@ internal byte[] RemoveLastDocument(BsonBuffer buffer)
var lastDocumentLength = buffer.Position - _lastDocumentStartPosition;
buffer.Position = _lastDocumentStartPosition;
var lastDocument = buffer.ReadBytes(lastDocumentLength);
+ buffer.Position = _lastDocumentStartPosition;
buffer.Length = _lastDocumentStartPosition;
BackpatchMessageLength(buffer);
return lastDocument;
@@ -68,6 +69,7 @@ internal byte[] RemoveLastDocument(BsonBuffer buffer)
internal void ResetBatch(BsonBuffer buffer, byte[] lastDocument)
{
buffer.Position = _firstDocumentStartPosition;
+ buffer.Length = _firstDocumentStartPosition;
buffer.WriteBytes(lastDocument);
BackpatchMessageLength(buffer);
}

0 comments on commit 7e7b57a

Please sign in to comment.