Skip to content

Commit

Permalink
Tar reader stuck with certain files and chunk sizes (#2698)
Browse files Browse the repository at this point in the history
Cannot share repeating tar files but when reading certain tar files the stage would get stuck waiting
for more data to be pushed but without having pulled upstream to actually get the next chunk.
  • Loading branch information
johanandren authored Jul 2, 2021
1 parent 9a27819 commit 7bf4a3a
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package akka.stream.alpakka.file.impl.archive

import java.util.concurrent.TimeUnit

import akka.NotUsed
import akka.annotation.InternalApi
import akka.stream.ActorAttributes.StreamSubscriptionTimeout
Expand Down Expand Up @@ -37,12 +36,15 @@ private[file] class TarReaderStage
extends SubSourceOutlet[ByteString]("fileOut")
with TarReaderStage.SourceWithTimeout

readHeader(ByteString.empty)
setHandlers(flowIn, flowOut, new CollectHeader(ByteString.empty))

def readHeader(buffer: ByteString): Unit = {
if (buffer.length >= TarArchiveEntry.headerLength) {
readFile(buffer)
} else setHandlers(flowIn, flowOut, new CollectHeader(buffer))
} else {
if (!hasBeenPulled(flowIn)) pull(flowIn)
setHandlers(flowIn, flowOut, new CollectHeader(buffer))
}
}

def readFile(headerBuffer: ByteString): Unit = {
Expand Down

0 comments on commit 7bf4a3a

Please sign in to comment.