I have some blocking code (a call to file.mkdirs()) that I am enclosing
inside blocking {} as below.

I have a feeling this may be incorrect. But I don't see a way to use
ActorAttributes in this scenario.

  // Is this the way to manage the blocking mkdirs?

  import scala.concurrent.blocking

  def mkdirs(file: File)(implicit ec: ExecutionContext): Future[(Boolean,
Boolean)] = Future {

    blocking {

      val madeDirs = file.getParentFile.mkdirs()

      val created = file.createNewFile()

      (madeDirs, created)

    }

  }

  def writeFile(source: Source[ByteString, akka.NotUsed], file: File)(
implicit ec: ExecutionContext, materializer: ActorMaterializer): Future[
IOResult] = {

    val result = for {

      madeDirs <- mkdirs(file)

      wroteBytes <- source/*.via(SnappyFlows.compress())*/.runWith(FileIO.
toFile(file))

    } yield wroteBytes

    result

  }

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to