Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

position is not increased in AsynchronousFileChannel.sink #685

Open
somdoron opened this issue Jun 17, 2024 · 0 comments
Open

position is not increased in AsynchronousFileChannel.sink #685

somdoron opened this issue Jun 17, 2024 · 0 comments

Comments

@somdoron
Copy link

somdoron commented Jun 17, 2024

In AsynchronousFileChannel.sink, the position is not increased when sending ByteBuffer to the underlying channel:
https://github.com/zio/zio-nio/blob/series/2.x/nio/jvm/src/main/scala/zio/nio/channels/AsynchronousFileChannel.scala#L162

 ZStream
   .repeatZIOWithSchedule(
     write(buffer, currentPos),
     Schedule.recurWhileZIO(Function.const(buffer.hasRemaining))
   )
   .runSum

Between each call to write here the position must be advanced. writeChunk seems to do it correctly:
https://github.com/zio/zio-nio/blob/series/2.x/nio/jvm/src/main/scala/zio/nio/channels/AsynchronousFileChannel.scala#L86

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant