aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/runtime/commands/CleanCommand.java
diff options
context:
space:
mode:
authorGravatar Benjamin Peterson <bp@benjamin.pe>2017-10-12 14:25:59 +0200
committerGravatar Marcel Hlopko <hlopko@google.com>2017-10-13 13:51:27 +0200
commitef143b46a48e3039e3a3ae6b4db3a0ab5210bbbb (patch)
tree7fbed3f3ed3f42e157c57e60b1141aa4f8c11e0e /src/main/java/com/google/devtools/build/lib/runtime/commands/CleanCommand.java
parent4646a9ab2602e62aa8a18c25beda2dac12cf5320 (diff)
Only delete the current execroot in clean.
I noticed a problem where if you have a workspace with basename "server", clean will rudely delete the server's pid file and cause it to commit suicide. This is because clean deletes the deep and non-deep execroot, presumably temporarily as part of the deep execroot migration. --deep_execroot has been enabled for more than a year now, so hopefully we can safely remove this aggressive deleting. --expunge can take care of old execroots if needed. Change-Id: I445b0d7cedf2fb9a6a365eacc85b75428a981640 PiperOrigin-RevId: 171948100
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/runtime/commands/CleanCommand.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/commands/CleanCommand.java18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/CleanCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/CleanCommand.java
index e4cb3ac7a3..88ff555570 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/commands/CleanCommand.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/CleanCommand.java
@@ -270,17 +270,13 @@ public final class CleanCommand implements BlazeCommand {
} else {
logger.info("Output cleaning...");
env.getBlazeWorkspace().resetEvaluator();
- // In order to be sure that we delete everything, delete the workspace directory both for
- // --deep_execroot and for --nodeep_execroot.
- for (String directory : new String[] {workspaceDirectory, "execroot"}) {
- Path child = outputBase.getRelative(directory);
- if (child.exists()) {
- logger.finest("Cleaning " + child + (async ? " asynchronously..." : ""));
- if (async) {
- asyncClean(env, child, "Output tree");
- } else {
- FileSystemUtils.deleteTreesBelow(child);
- }
+ Path execroot = outputBase.getRelative("execroot");
+ if (execroot.exists()) {
+ logger.finest("Cleaning " + execroot + (async ? " asynchronously..." : ""));
+ if (async) {
+ asyncClean(env, execroot, "Output tree");
+ } else {
+ FileSystemUtils.deleteTreesBelow(execroot);
}
}
}