mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Add support for archive files
Each attachment is now first extracted into potentially multiple ones, if it is recognized as an archive. This is the first step in processing. The original archive file is also stored and the resulting attachments are associated to their original archive. First support is implemented for zip files.
This commit is contained in:
BIN
modules/files/src/test/resources/letters.zip
Normal file
BIN
modules/files/src/test/resources/letters.zip
Normal file
Binary file not shown.
30
modules/files/src/test/scala/docspell/files/ZipTest.scala
Normal file
30
modules/files/src/test/scala/docspell/files/ZipTest.scala
Normal file
@ -0,0 +1,30 @@
|
||||
package docspell.files
|
||||
|
||||
import minitest._
|
||||
import cats.effect._
|
||||
import cats.implicits._
|
||||
import scala.concurrent.ExecutionContext
|
||||
|
||||
object ZipTest extends SimpleTestSuite {
|
||||
|
||||
val blocker = Blocker.liftExecutionContext(ExecutionContext.global)
|
||||
implicit val CS = IO.contextShift(ExecutionContext.global)
|
||||
|
||||
test("unzip") {
|
||||
val zipFile = ExampleFiles.letters_zip.readURL[IO](8192, blocker)
|
||||
val uncomp = zipFile.through(Zip.unzip(8192, blocker))
|
||||
|
||||
uncomp.evalMap(entry => {
|
||||
val x = entry.data.map(_ => 1).foldMonoid.compile.lastOrError
|
||||
x.map(size => {
|
||||
if (entry.name.endsWith(".pdf")) {
|
||||
assertEquals(entry.name, "letter-de.pdf")
|
||||
assertEquals(size, 34815)
|
||||
} else {
|
||||
assertEquals(entry.name, "letter-en.txt")
|
||||
assertEquals(size, 1131)
|
||||
}
|
||||
})
|
||||
}).compile.drain.unsafeRunSync
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user