This commit is contained in:
folex 2019-06-15 13:53:02 +02:00
parent f7f3fe61c1
commit 17abc4f045
2 changed files with 3 additions and 4 deletions

View File

@ -4,7 +4,6 @@ import java.nio.file.{Path, StandardOpenOption}
import java.util.concurrent.Executors import java.util.concurrent.Executors
import cats.effect.{Concurrent, ContextShift, Resource, Sync} import cats.effect.{Concurrent, ContextShift, Resource, Sync}
import cats.syntax.functor._
import fs2.io.Watcher import fs2.io.Watcher
import fs2.{Pull, text} import fs2.{Pull, text}
@ -31,13 +30,13 @@ class FileStream[F[_]: Sync: ContextShift: Concurrent](
.flatMap { case (start, end) => readRange(start, end) } .flatMap { case (start, end) => readRange(start, end) }
} }
def readRange(start: Long, end: Long) = private def readRange(start: Long, end: Long) =
fs2.io.file fs2.io.file
.readRange[F](path, blocking, ChunkSize, start, end) .readRange[F](path, blocking, ChunkSize, start, end)
.through(text.utf8Decode) .through(text.utf8Decode)
.through(text.lines) .through(text.lines)
val fileSizeStream: fs2.Stream[F, Long] = private val fileSizeStream: fs2.Stream[F, Long] =
fs2.io.file.pulls fs2.io.file.pulls
.fromPath[F](path, blocking, Seq(StandardOpenOption.READ)) .fromPath[F](path, blocking, Seq(StandardOpenOption.READ))
.flatMap(c => Pull.eval(c.resource.size)) .flatMap(c => Pull.eval(c.resource.size))