diff --git a/LiteDB/Engine/Sort/SortDisk.cs b/LiteDB/Engine/Sort/SortDisk.cs index 501b93d76..7641259d9 100644 --- a/LiteDB/Engine/Sort/SortDisk.cs +++ b/LiteDB/Engine/Sort/SortDisk.cs @@ -88,8 +88,11 @@ public void Write(long position, BufferSlice buffer) // there is only a single writer instance, must be lock to ensure only 1 single thread are writing lock(writer) { - writer.Position = position; - writer.Write(buffer.Array, buffer.Offset, _containerSize); + for (var i = 0; i < _containerSize / PAGE_SIZE; ++i) + { + writer.Position = position + i * PAGE_SIZE; + writer.Write(buffer.Array, buffer.Offset + i * PAGE_SIZE, PAGE_SIZE); + } } }