Skip to content

Commit

Permalink
Update commons compress
Browse files Browse the repository at this point in the history
  • Loading branch information
StepanBrychta committed Oct 7, 2024
1 parent 36346e9 commit 6bd6974
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ trait Unpacker[
case err: IOException
if err.getMessage == "Error detected parsing the header" =>
UnpackerUnarchiverError(UnexpectedUnarchiverError(err))
case err: IOException if err.getMessage.startsWith("unexpected EOF") =>
case err: IOException if err.getMessage.startsWith("unexpected EOF") || err.getMessage.startsWith("Truncated TAR archive") =>
UnpackerEOFError(err)
case err => UnpackerUnexpectedError(err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,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 @@ -90,13 +90,13 @@ 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))
.asInstanceOf[ArchiveInputStream]
.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 @@ -2,16 +2,9 @@ package weco.storage_service.bag_unpacker.fixtures

import java.io.{File, _}
import grizzled.slf4j.Logging
import org.apache.commons.compress.archivers.{
ArchiveEntry,
ArchiveOutputStream,
ArchiveStreamFactory
}
import org.apache.commons.compress.compressors.{
CompressorOutputStream,
CompressorStreamFactory
}
import org.apache.commons.io.IOUtils
import org.apache.commons.compress.archivers.{ArchiveEntry, ArchiveOutputStream, ArchiveStreamFactory}
import org.apache.commons.compress.compressors.{CompressorOutputStream, CompressorStreamFactory}
import org.scalatest.matchers.should.Matchers
import weco.fixtures.TestWith
import weco.storage_service.generators.StorageRandomGenerators
Expand Down Expand Up @@ -146,6 +139,7 @@ trait CompressFixture[BagLocation <: Location, Namespace]
def finish(): Unit = {
archiveOutputStream.flush()
archiveOutputStream.finish()
archiveOutputStream.close()
compressorOutputStream.flush()
compressorOutputStream.close()
}
Expand Down Expand Up @@ -182,7 +176,7 @@ trait CompressFixture[BagLocation <: Location, Namespace]
compressorName: String
)(
outputStream: OutputStream
): CompressorOutputStream = {
): CompressorOutputStream[BufferedOutputStream] = {

val compressorStreamFactory =
new CompressorStreamFactory()
Expand All @@ -195,13 +189,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
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ object ExternalDependencies {
lazy val versions = new {

val azure = "12.25.4"
val commonsCompress = "1.5"
val commonsCompress = "1.27.1"
val commonsIO = "2.17.0"
val mockito = "5.13.0"
val scalatest = "3.2.19"
Expand Down

0 comments on commit 6bd6974

Please sign in to comment.