mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Adopt deprecated APIs from fs2; use fs2.Path
This commit is contained in:
@ -7,7 +7,6 @@
|
||||
package docspell.files
|
||||
|
||||
import java.io.{ByteArrayInputStream, InputStream}
|
||||
import java.nio.file.Path
|
||||
import javax.imageio.stream.{FileImageInputStream, ImageInputStream}
|
||||
import javax.imageio.{ImageIO, ImageReader}
|
||||
|
||||
@ -17,6 +16,7 @@ import scala.util.{Try, Using}
|
||||
import cats.effect._
|
||||
import cats.implicits._
|
||||
import fs2.Stream
|
||||
import fs2.io.file.Path
|
||||
|
||||
object ImageSize {
|
||||
|
||||
@ -24,7 +24,7 @@ object ImageSize {
|
||||
* the whole image into memory.
|
||||
*/
|
||||
def get(file: Path): Option[Dimension] =
|
||||
Using(new FileImageInputStream(file.toFile))(getDimension).toOption.flatten
|
||||
Using(new FileImageInputStream(file.toNioPath.toFile))(getDimension).toOption.flatten
|
||||
|
||||
/** Return the image size from its header without reading
|
||||
* the whole image into memory.
|
||||
|
@ -8,7 +8,7 @@ package docspell.files
|
||||
|
||||
import java.io.BufferedInputStream
|
||||
import java.nio.charset.Charset
|
||||
import java.nio.file.{Files, Path}
|
||||
import java.nio.file.Files
|
||||
|
||||
import scala.jdk.CollectionConverters._
|
||||
import scala.util.Using
|
||||
@ -16,6 +16,7 @@ import scala.util.Using
|
||||
import cats.effect.Sync
|
||||
import cats.implicits._
|
||||
import fs2.Stream
|
||||
import fs2.io.file.Path
|
||||
|
||||
import docspell.common._
|
||||
|
||||
@ -100,8 +101,8 @@ object TikaMimetype {
|
||||
|
||||
def detect[F[_]: Sync](file: Path): F[MimeType] =
|
||||
Sync[F].delay {
|
||||
val hint = MimeTypeHint.filename(file.getFileName.toString)
|
||||
Using(new BufferedInputStream(Files.newInputStream(file), 64)) { in =>
|
||||
val hint = MimeTypeHint.filename(file.fileName.toString)
|
||||
Using(new BufferedInputStream(Files.newInputStream(file.toNioPath), 64)) { in =>
|
||||
convert(tika.detect(in, makeMetadata(hint)))
|
||||
}.toEither
|
||||
}.rethrow
|
||||
|
Reference in New Issue
Block a user