Skip to content

Commit

Permalink
Revert "Better exception messages, refactoring"
Browse files Browse the repository at this point in the history
This reverts commit 3b00df3.
  • Loading branch information
eed3si9n committed Jun 25, 2018
1 parent 7cdc5f0 commit 301367d
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions io/src/main/scala/sbt/io/IO.scala
Original file line number Diff line number Diff line change
Expand Up @@ -463,34 +463,34 @@ object IO {
/** Deletes `file`, recursively if it is a directory. */
def delete(file: File): Unit = {
object deleter extends SimpleFileVisitor[NioPath] {
def deletePath(path: NioPath) =
translate("Error deleting " + path.toFile + ": ") {
override def visitFile(file: NioPath, attr: BasicFileAttributes): FileVisitResult = {
translate("Error deleting file " + file.toFile + ": ") {
try {
Files.delete(path)
Files.delete(file)
} catch {
case _: NoSuchFileException => // ignore missing files
case e: NoSuchFileException =>
}
}

override def visitFile(filePath: NioPath, attr: BasicFileAttributes): FileVisitResult = {
deletePath(filePath)
FileVisitResult.CONTINUE
}

override def postVisitDirectory(dirPath: NioPath, e: IOException): FileVisitResult = {
override def postVisitDirectory(dir: NioPath, e: IOException): FileVisitResult = {
if (e eq null) {
deletePath(dirPath)
translate("Error deleting file " + dir.toFile + ": ") {
try {
Files.delete(dir)
} catch {
case e: NoSuchFileException =>
}
}
FileVisitResult.CONTINUE
} else throw e // directory iteration failed
}
}
translate("Error during a recursive delete of path " + file + ": ") {
try {
Files.walkFileTree(file.toPath, deleter)
()
} catch {
case _: NoSuchFileException => // ignore missing file or dir
}
try {
Files.walkFileTree(file.toPath, deleter)
} catch {
case e: NoSuchFileException =>
}
}

Expand Down

0 comments on commit 301367d

Please sign in to comment.