in app/services/ZipReader.scala [73:94]
def locateBuildInfoContent():Try[Option[ByteString]] = withStreams(zipStream => {
import cats.implicits._
def traverseEntries():Option[Try[ByteString]] = Option(zipStream.getNextEntry) match {
case Some(entry) =>
if (entry.getName.endsWith("build-info.yaml")) {
logger.debug(s"found build-info.yaml at ${entry.getName}, streaming the content")
val content = readContent(zipStream).map(ByteString.apply)
zipStream.closeEntry()
Some(content)
} else {
zipStream.closeEntry()
traverseEntries()
}
case None=>
logger.debug("reached end of zip file, no build-info found")
None
}
//use cats to turn the Option[Try[ByteString]] into a Try[Option[ByteString]]
traverseEntries().sequence
})