@@ -54,6 +54,10 @@ import kotlinx.coroutines.flow.emitAll
5454import kotlinx.coroutines.flow.flow
5555import kotlinx.coroutines.launch
5656import kotlinx.coroutines.withContext
57+ import kotlinx.io.Sink
58+ import kotlinx.io.buffered
59+ import kotlinx.io.files.Path
60+ import kotlinx.io.files.SystemFileSystem
5761import kotlinx.serialization.SerialName
5862import kotlinx.serialization.Serializable
5963import kotlinx.serialization.json.JsonObject
@@ -258,7 +262,9 @@ internal class SyncStream(
258262
259263 private suspend fun streamingSyncIteration () {
260264 coroutineScope {
261- val iteration = ActiveIteration (this )
265+ val file = SystemFileSystem .sink(Path (" /Users/simon/test.bin" )).buffered()
266+
267+ val iteration = ActiveIteration (this , dumpSyncLines = file)
262268
263269 try {
264270 iteration.start()
@@ -267,6 +273,7 @@ internal class SyncStream(
267273 // clean up resources.
268274 withContext(NonCancellable ) {
269275 iteration.stop()
276+ file.close()
270277 }
271278 }
272279 }
@@ -276,6 +283,7 @@ internal class SyncStream(
276283 val scope : CoroutineScope ,
277284 var fetchLinesJob : Job ? = null ,
278285 var credentialsInvalidation : Job ? = null ,
286+ var dumpSyncLines : Sink
279287 ) {
280288 suspend fun start () {
281289 control(" start" , JsonUtil .json.encodeToString(params))
@@ -360,7 +368,10 @@ internal class SyncStream(
360368 }
361369 }
362370 }
363- Instruction .DidCompleteSync -> status.update { copy(downloadError= null ) }
371+ Instruction .DidCompleteSync -> {
372+ dumpSyncLines.flush()
373+ status.update { copy(downloadError= null ) }
374+ }
364375 is Instruction .UnknownInstruction -> {
365376 throw PowerSyncException (" Unknown instruction received from core extension: ${instruction.raw} " , null )
366377 }
0 commit comments