Hi,
I am new to Akka and Alpakka so appreciate any help please.
I am trying to save a tar.gz file, then unpack it and save the unpacked files, then read one of the unpacked files for further processing. This means somewhere the system has to wait for the tar.gz to be written and for the unpacking to finish before the file can be read again.
I am stuck with how to wait for this (not using Await).
The structure looks something like this:
Source
.via(download the tar.gz file and save it to disc)
.via(untarFiles and save to disc)
.via(read one of the unpacked files and process)
.toMat(Sink.foreach(println))(Keep.both).run()
With a few more comments:
Source
.via(download the tar.gz file and save) // save the file using: dataBytes.runWith(FileIO.toPath(new File(tarFileLocation).toPath)) which returns a Future[IOResult].
.via(untarFiles and save to disc) //File • Alpakka Documentation but the problem is that the tar.gz file has not finished writing yet and hence does not exist yet. I am using val bytesSource = Source.single(ByteString(Files.readAllBytes(Paths.get(tarFileLocation)))) to read the file but it’s not there yet. I also need to pass the file-name of the unpacked file on to then read.
.via(read one of the unpacked files and process)//the unpacked file is not there yet as the untarFile has not finished yet
.toMat(Sink.foreach(println))(Keep.both).run()
Thank you very much!
1 post - 1 participant