zio / zio-nio

A small, unopinionated ZIO interface to NIO.
https://zio.dev/zio-nio
Apache License 2.0
188 stars 75 forks source link

Files.deleteRecursive does not delete recursively #586

Open hbibel opened 1 year ago

hbibel commented 1 year ago

Hi all,

Files.deleteRecursive fails when passed a directory that contains a non-empty directory. I tested this using zio 2.0.10, zio-nio 2.0.1 and JDK "Temurin" 17.0.5:

import zio._
import zio.nio.file._

object DeleteRecursivelyTest extends ZIOAppDefault {
  override def run = {
    val dirPath = Path("delete-test")
    for {
      _ <- Files.createDirectories(dirPath / "inner")
      _ <- Files.writeLines(dirPath / "inner" / "blah.txt", Seq("test"))
      _ <- Files.deleteRecursive(dirPath)
    } yield ExitCode.success
  }

}

I believe this is not intended behavior.

hbibel commented 1 year ago

Hi all,

I opened a PR with a basic implementation for the desired functionality. I marked it as WIP since there's a couple of things that aren't clear to me:

Thanks for any feedback!