diff options
author | Adam Michael <ajmichael@google.com> | 2016-12-09 22:19:32 +0000 |
---|---|---|
committer | John Cater <jcater@google.com> | 2016-12-12 20:35:14 +0000 |
commit | b5f480cb7c79ccbd938e5892834736dd4d3b5eef (patch) | |
tree | a7475de98fcd51498819d448a5e59539950093ef /src/main/java/com/google/devtools/build/lib/sandbox | |
parent | fd93143f93a9873218cd2eb783a0bff322847213 (diff) |
Sandbox should not mount directory for nonempty tree artifacts.
Instead they mount the individual files. Currently, non-empty tree artifacts result in ERR_DIRECTORY_NOT_EMPTY because we attempt to mount both the directory and the files inside it.
Fixes https://github.com/bazelbuild/bazel/issues/1745.
--
PiperOrigin-RevId: 141599030
MOS_MIGRATED_REVID=141599030
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/sandbox')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/sandbox/SpawnHelpers.java | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/SpawnHelpers.java b/src/main/java/com/google/devtools/build/lib/sandbox/SpawnHelpers.java index 1bfa16b197..0abf331917 100644 --- a/src/main/java/com/google/devtools/build/lib/sandbox/SpawnHelpers.java +++ b/src/main/java/com/google/devtools/build/lib/sandbox/SpawnHelpers.java @@ -30,6 +30,7 @@ import com.google.devtools.build.lib.vfs.PathFragment; import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -193,8 +194,14 @@ public final class SpawnHelpers { // inputs. for (ActionInput input : spawn.getInputFiles()) { if (input instanceof Artifact && ((Artifact) input).isTreeArtifact()) { - PathFragment mount = new PathFragment(input.getExecPathString()); - mounts.put(mount, execRoot.getRelative(mount)); + List<Artifact> containedArtifacts = new ArrayList<>(); + actionExecutionContext.getArtifactExpander().expand((Artifact) input, containedArtifacts); + // Attempting to mount a non-empty directory results in ERR_DIRECTORY_NOT_EMPTY, so we only + // mount empty TreeArtifacts as directories. + if (containedArtifacts.isEmpty()) { + PathFragment mount = new PathFragment(input.getExecPathString()); + mounts.put(mount, execRoot.getRelative(mount)); + } } } |