Skip to content

Commit

Permalink
Fix failing unarchiver test
Browse files Browse the repository at this point in the history
  • Loading branch information
StepanBrychta committed Oct 2, 2024
1 parent 2d270d5 commit 42fa951
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
package weco.storage_service.bag_unpacker.storage

import java.io.{BufferedInputStream, InputStream}

import org.apache.commons.compress.archivers.{
ArchiveEntry,
ArchiveException,
ArchiveInputStream,
ArchiveStreamFactory
}
import org.apache.commons.compress.compressors.{
CompressorException,
CompressorInputStream,
CompressorStreamFactory
}
import java.io.{BufferedInputStream, InputStream}
import org.apache.commons.compress.archivers.{ArchiveEntry, ArchiveException, ArchiveInputStream, ArchiveStreamFactory}
import org.apache.commons.compress.compressors.{CompressorException, CompressorInputStream, CompressorStreamFactory}
import org.apache.commons.io.input.CloseShieldInputStream

import scala.util.{Failure, Success, Try}
Expand Down Expand Up @@ -51,7 +42,7 @@ object Unarchiver {
} yield iterator

private def createIterator(
archiveInputStream: ArchiveInputStream
archiveInputStream: ArchiveInputStream[ArchiveEntry]
): Iterator[(ArchiveEntry, InputStream)] =
new Iterator[(ArchiveEntry, InputStream)] {
private var latest: ArchiveEntry = _
Expand Down Expand Up @@ -92,12 +83,12 @@ object Unarchiver {

private def extract(
inputStream: InputStream
): Either[UnarchiverError, ArchiveInputStream] =
): Either[UnarchiverError, ArchiveInputStream[ArchiveEntry]] =
Try {
// We have to wrap in a BufferedInputStream because this method
// only takes InputStreams that support the `mark()` method.
new ArchiveStreamFactory()
.createArchiveInputStream(new BufferedInputStream(inputStream))
.createArchiveInputStream(new BufferedInputStream(inputStream)).asInstanceOf[ArchiveInputStream[ArchiveEntry]]
} match {
case Success(stream) => Right(stream)
case Failure(err: ArchiveException) => Left(ArchiveFormatError(err))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ trait CompressFixture[BagLocation <: Location, Namespace]
compressorName: String
)(
outputStream: OutputStream
): CompressorOutputStream = {
): CompressorOutputStream[BufferedOutputStream] = {

val compressorStreamFactory =
new CompressorStreamFactory()
Expand All @@ -195,13 +195,13 @@ trait CompressFixture[BagLocation <: Location, Namespace]
compressorName,
bufferedOutputStream
)
}
}.asInstanceOf[CompressorOutputStream[BufferedOutputStream]]

private def packer(
archiverName: String
)(
outputStream: OutputStream
): ArchiveOutputStream = {
): ArchiveOutputStream[ArchiveEntry] = {

val archiveStreamFactory =
new ArchiveStreamFactory()
Expand Down

0 comments on commit 42fa951

Please sign in to comment.