mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-21 18:08:25 +00:00
Update scalafmt to 2.5.1 + scalafmtAll
This commit is contained in:
@ -36,24 +36,25 @@ object TikaMimetype {
|
||||
md
|
||||
}
|
||||
|
||||
private def normalize(in: MimeType): MimeType = in match {
|
||||
case MimeType(_, sub, p) if sub contains "xhtml" =>
|
||||
MimeType.html.copy(params = p)
|
||||
case _ => in
|
||||
}
|
||||
private def normalize(in: MimeType): MimeType =
|
||||
in match {
|
||||
case MimeType(_, sub, p) if sub contains "xhtml" =>
|
||||
MimeType.html.copy(params = p)
|
||||
case _ => in
|
||||
}
|
||||
|
||||
private def fromBytes(bv: Array[Byte], hint: MimeTypeHint): MimeType = {
|
||||
val mt = convert(
|
||||
tika.detect(new java.io.ByteArrayInputStream(bv), makeMetadata(hint))
|
||||
)
|
||||
if (mt.primary == "text") {
|
||||
if (mt.primary == "text")
|
||||
charsetFromBytes(bv, hint) match {
|
||||
case Some(cs) =>
|
||||
mt.withCharset(cs)
|
||||
case None =>
|
||||
mt
|
||||
}
|
||||
} else mt
|
||||
else mt
|
||||
}
|
||||
|
||||
private def charsetFromBytes(bv: Array[Byte], hint: MimeTypeHint): Option[Charset] =
|
||||
|
@ -8,20 +8,22 @@ import scala.concurrent.ExecutionContext
|
||||
object Playing extends IOApp {
|
||||
val blocker = Blocker.liftExecutionContext(ExecutionContext.global)
|
||||
|
||||
def run(args: List[String]): IO[ExitCode] = IO {
|
||||
//val ods = ExampleFiles.examples_sample_ods.readURL[IO](8192, blocker)
|
||||
//val odt = ExampleFiles.examples_sample_odt.readURL[IO](8192, blocker)
|
||||
val rtf = ExampleFiles.examples_sample_rtf.readURL[IO](8192, blocker)
|
||||
def run(args: List[String]): IO[ExitCode] =
|
||||
IO {
|
||||
//val ods = ExampleFiles.examples_sample_ods.readURL[IO](8192, blocker)
|
||||
//val odt = ExampleFiles.examples_sample_odt.readURL[IO](8192, blocker)
|
||||
val rtf = ExampleFiles.examples_sample_rtf.readURL[IO](8192, blocker)
|
||||
|
||||
val x = for {
|
||||
odsm1 <- TikaMimetype
|
||||
.detect(
|
||||
rtf,
|
||||
MimeTypeHint.filename(ExampleFiles.examples_sample_rtf.path.segments.last)
|
||||
)
|
||||
odsm2 <- TikaMimetype.detect(rtf, MimeTypeHint.none)
|
||||
} yield (odsm1, odsm2)
|
||||
println(x.unsafeRunSync())
|
||||
ExitCode.Success
|
||||
}
|
||||
val x = for {
|
||||
odsm1 <-
|
||||
TikaMimetype
|
||||
.detect(
|
||||
rtf,
|
||||
MimeTypeHint.filename(ExampleFiles.examples_sample_rtf.path.segments.last)
|
||||
)
|
||||
odsm2 <- TikaMimetype.detect(rtf, MimeTypeHint.none)
|
||||
} yield (odsm1, odsm2)
|
||||
println(x.unsafeRunSync())
|
||||
ExitCode.Success
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user