Skip to content

Commit

Permalink
Use strings for fileset target paths in ActionInputMetadataProvider.
Browse files Browse the repository at this point in the history
Avoids creating a `PathFragment` wrapper. The strings are already normalized because they come from `FilesetOutputSymlink#getTargetPath`.

PiperOrigin-RevId: 675633107
Change-Id: I8677c9651756539e7110f8035ba60c0d36e2fff5
  • Loading branch information
justinhorvitz authored and copybara-github committed Sep 17, 2024
1 parent 4093943 commit d2a9765
Showing 1 changed file with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ final class ActionInputMetadataProvider implements InputMetadataProvider {
private final PathFragment execRoot;

private final ActionInputMap inputArtifactData;
private final ImmutableMap<PathFragment, FileArtifactValue> filesetMapping;

/** Mapping from a fileset entry's target path to its metadata. */
private final ImmutableMap<String, FileArtifactValue> filesetMapping;

ActionInputMetadataProvider(
PathFragment execRoot,
Expand All @@ -56,18 +58,21 @@ final class ActionInputMetadataProvider implements InputMetadataProvider {
this.filesetMapping = createFilesetMapping(filesets, execRoot);
}

private static ImmutableMap<PathFragment, FileArtifactValue> createFilesetMapping(
private static ImmutableMap<String, FileArtifactValue> createFilesetMapping(
Map<Artifact, ImmutableList<FilesetOutputSymlink>> filesets, PathFragment execRoot) {
Map<PathFragment, FileArtifactValue> filesetMap = new HashMap<>();
for (Map.Entry<Artifact, ImmutableList<FilesetOutputSymlink>> entry : filesets.entrySet()) {
FilesetManifest fileset =
Map<String, FileArtifactValue> filesetMap = new HashMap<>();
for (ImmutableList<FilesetOutputSymlink> links : filesets.values()) {
FilesetManifest manifest =
FilesetManifest.constructFilesetManifestWithoutError(
entry.getValue(), execRoot, RelativeSymlinkBehaviorWithoutError.RESOLVE);
for (Map.Entry<String, FileArtifactValue> favEntry : fileset.getArtifactValues().entrySet()) {
if (favEntry.getValue().getDigest() != null) {
filesetMap.put(PathFragment.create(favEntry.getKey()), favEntry.getValue());
}
}
links, execRoot, RelativeSymlinkBehaviorWithoutError.RESOLVE);
manifest
.getArtifactValues()
.forEach(
(targetPath, metadata) -> {
if (metadata.getDigest() != null) {
filesetMap.put(targetPath, metadata);
}
});
}
return ImmutableMap.copyOf(filesetMap);
}
Expand All @@ -79,7 +84,7 @@ public FileArtifactValue getInputMetadata(ActionInput actionInput) throws IOExce
PathFragment inputPath = actionInput.getExecPath();
PathFragment filesetKeyPath =
inputPath.startsWith(execRoot) ? inputPath.relativeTo(execRoot) : inputPath;
return filesetMapping.get(filesetKeyPath);
return filesetMapping.get(filesetKeyPath.getPathString());
}

FileArtifactValue value;
Expand Down

0 comments on commit d2a9765

Please sign in to comment.