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/test/java/com/google/devtools/build/lib/standalone/StandaloneSpawnStrategyTest.java b/src/test/java/com/google/devtools/build/lib/standalone/StandaloneSpawnStrategyTest.java
index 2dbcced..42cb2c6 100644
--- a/src/test/java/com/google/devtools/build/lib/standalone/StandaloneSpawnStrategyTest.java
+++ b/src/test/java/com/google/devtools/build/lib/standalone/StandaloneSpawnStrategyTest.java
@@ -53,7 +53,6 @@
import com.google.devtools.build.lib.util.OS;
import com.google.devtools.build.lib.util.io.FileOutErr;
import com.google.devtools.build.lib.vfs.FileSystem;
-import com.google.devtools.build.lib.vfs.FileSystemUtils;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.util.FileSystems;
import com.google.devtools.common.options.Options;
@@ -89,7 +88,7 @@
fileSystem = FileSystems.getNativeFileSystem();
Path testRoot = fileSystem.getPath(TestUtils.tmpDir());
try {
- FileSystemUtils.deleteTreesBelow(testRoot);
+ testRoot.deleteTreesBelow();
} catch (IOException e) {
System.err.println("Failed to remove directory " + testRoot + ": " + e.getMessage());
throw e;