Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Files.deleteRecursive does not delete recursively #586

Open
hbibel opened this issue Mar 24, 2023 · 1 comment
Open

Files.deleteRecursive does not delete recursively #586

hbibel opened this issue Mar 24, 2023 · 1 comment

Comments

@hbibel
Copy link
Contributor

hbibel commented Mar 24, 2023

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
Copy link
Contributor Author

hbibel commented Apr 1, 2023

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:

  • What is the exact meaning of the effect's result value? Should it record the number of deleted files? Or files + directories?
  • What should be the behavior for symlinks? I'd suggest adding the ability to pass LinkOptions like in other methods to enable control over whether a linked directory gets wiped as well.

Thanks for any feedback!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant