Move deleteTree and deleteTreesBelow into FileSystem and Path.
The current implementation of these functions is very inefficient and
degrades overall performance significantly, especially when sandboxing is
enabled. However, that's almost the best we can do with a generic
algorithm.
To make room for optimizations that rely on specific file system features,
move these functions into the FileSystem class. I will supply a custom
implementation for UnixFileSystem later.
Note that this is intended to be a pure code move. I haven't applied any
improvements to the code nor tests yet (with the exception of cleaning up
docstrings).
Addresses https://github.com/bazelbuild/bazel/issues/7527.
RELNOTES: None.
PiperOrigin-RevId: 239412965
diff --git a/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java b/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java
index 05d8cb8..d648150 100644
--- a/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java
+++ b/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java
@@ -465,7 +465,7 @@
Path directory = env.getActionConsoleOutputDirectory();
try {
if (directory.exists()) {
- FileSystemUtils.deleteTree(directory);
+ directory.deleteTree();
}
FileSystemUtils.createDirectoryAndParents(directory);
} catch (IOException e) {