mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Improve performance of zip/unzip
Adds tests and includes some cleanup
This commit is contained in:
@ -13,7 +13,7 @@ import fs2.io.file.{Files, Path, PosixPermissions}
|
||||
|
||||
import docspell.addons.out.AddonOutput
|
||||
import docspell.common.LenientUri
|
||||
import docspell.files.Zip
|
||||
import docspell.common.util.Zip
|
||||
|
||||
import io.circe.syntax._
|
||||
|
||||
@ -59,9 +59,9 @@ object AddonGenerator {
|
||||
private def createZip(dir: Path, files: List[Path]) =
|
||||
Stream
|
||||
.emits(files)
|
||||
.map(f => (f.fileName.toString, Files[IO].readAll(f)))
|
||||
.map(f => (f.fileName.toString, f))
|
||||
.covary[IO]
|
||||
.through(Zip.zip[IO](logger, 8192))
|
||||
.through(Zip[IO](logger.some).zipFiles())
|
||||
.through(Files[IO].writeAll(dir / "addon.zip"))
|
||||
.compile
|
||||
.drain
|
||||
|
@ -7,9 +7,10 @@
|
||||
package docspell.addons
|
||||
|
||||
import cats.effect._
|
||||
import cats.syntax.all._
|
||||
|
||||
import docspell.common.Glob
|
||||
import docspell.files.Zip
|
||||
import docspell.common.util.{Directory, Zip}
|
||||
import docspell.logging.TestLoggingConfig
|
||||
|
||||
import munit._
|
||||
@ -26,8 +27,8 @@ class AddonMetaTest extends CatsEffectSuite with TestLoggingConfig with Fixtures
|
||||
for {
|
||||
_ <- dummyAddonUrl
|
||||
.readURL[IO](8192)
|
||||
.through(Zip.unzip(8192, Glob.all))
|
||||
.through(Zip.saveTo(logger, dir, moveUp = true))
|
||||
.through(Zip[IO]().unzip(8192, Glob.all, dir.some))
|
||||
.evalTap(_ => Directory.unwrapSingle(logger, dir))
|
||||
.compile
|
||||
.drain
|
||||
meta <- AddonMeta.findInDirectory[IO](dir)
|
||||
|
Reference in New Issue
Block a user