mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Updated following dependencies as they need changes to the code to work properly:
- Scala - fs2 - http4s
This commit is contained in:
@ -39,7 +39,7 @@ final case class Binary[F[_]](name: String, mime: MimeType, data: Stream[F, Byte
|
||||
|
||||
object Binary {
|
||||
|
||||
def apply[F[_]: Async](file: Path): Binary[F] =
|
||||
def apply[F[_]: Files](file: Path): Binary[F] =
|
||||
Binary(file.fileName.toString, Files[F].readAll(file))
|
||||
|
||||
def apply[F[_]](name: String, data: Stream[F, Byte]): Binary[F] =
|
||||
@ -74,11 +74,11 @@ object Binary {
|
||||
data.chunks.map(_.toByteVector).compile.fold(ByteVector.empty)((r, e) => r ++ e)
|
||||
|
||||
/** Convert paths into `Binary`s */
|
||||
def toBinary[F[_]: Async]: Pipe[F, Path, Binary[F]] =
|
||||
def toBinary[F[_]: Files]: Pipe[F, Path, Binary[F]] =
|
||||
_.map(Binary[F](_))
|
||||
|
||||
/** Save one or more binaries to a target directory. */
|
||||
def saveTo[F[_]: Async](
|
||||
def saveTo[F[_]: Async: Files](
|
||||
logger: Logger[F],
|
||||
targetDir: Path
|
||||
): Pipe[F, Binary[F], Path] =
|
||||
|
@ -72,6 +72,6 @@ object File {
|
||||
.drain
|
||||
.map(_ => file)
|
||||
|
||||
def readJson[F[_]: Async, A](file: Path)(implicit d: Decoder[A]): F[A] =
|
||||
def readJson[F[_]: Async: Files, A](file: Path)(implicit d: Decoder[A]): F[A] =
|
||||
readText[F](file).map(parser.decode[A]).rethrow
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
package docspell.common.util
|
||||
|
||||
import cats.effect._
|
||||
import fs2.io.file.Path
|
||||
import fs2.io.file.{Files, Path}
|
||||
import fs2.{Pipe, Stream}
|
||||
|
||||
import docspell.common.Glob
|
||||
@ -33,9 +33,9 @@ trait Zip[F[_]] {
|
||||
}
|
||||
|
||||
object Zip {
|
||||
val defaultChunkSize = 64 * 1024
|
||||
private val defaultChunkSize = 64 * 1024
|
||||
|
||||
def apply[F[_]: Async](
|
||||
def apply[F[_]: Async: Files](
|
||||
logger: Option[Logger[F]] = None,
|
||||
tempDir: Option[Path] = None
|
||||
): Zip[F] =
|
||||
|
@ -22,7 +22,7 @@ import fs2.{Chunk, Pipe, Stream}
|
||||
import docspell.common.Glob
|
||||
import docspell.logging.Logger
|
||||
|
||||
final private class ZipImpl[F[_]: Async](
|
||||
final private class ZipImpl[F[_]: Async: Files](
|
||||
log: Option[Logger[F]],
|
||||
tempDir: Option[Path]
|
||||
) extends Zip[F] {
|
||||
|
Reference in New Issue
Block a user