Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ByteStreamBuildEventArtifactUploader: skip reading metadata for files that won't be uploaded #20575

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,17 @@ public DigestFunction.Value getDigestFunction() {
private PathMetadata readPathMetadata(Path path, LocalFile file) throws IOException {
DigestUtil digestUtil = new DigestUtil(xattrProvider, path.getFileSystem().getDigestFunction());

if (!shouldUploadFilename(path.getPathString())) {
return new PathMetadata(
path,
/* digest= */ null,
/* directory= */ false,
/* symlink= */ true,
/* remote= */ false,
/* omitted= */ false,
/* digestFunction= */ digestUtil.getDigestFunction());
}

if (file.type == LocalFileType.OUTPUT_DIRECTORY
|| ((file.type == LocalFileType.SUCCESSFUL_TEST_OUTPUT
|| file.type == LocalFileType.FAILED_TEST_OUTPUT
Expand Down Expand Up @@ -277,20 +288,23 @@ private boolean shouldUpload(PathMetadata path) {
&& !path.isSymlink()
&& !path.isOmitted();

if (remoteBuildEventUploadMode == RemoteBuildEventUploadMode.MINIMAL) {
result = result && (isLog(path) || isProfile(path));
}
String filename = path.getPath().getPathString();
result = result && shouldUploadFilename(filename);

return result;
}

private boolean isLog(PathMetadata path) {
return TEST_LOG_PATTERN.matcher(path.getPath().getPathString()).matches()
|| BUILD_LOG_PATTERN.matcher(path.getPath().getPathString()).matches();
private boolean shouldUploadFilename(String filename) {
return remoteBuildEventUploadMode != RemoteBuildEventUploadMode.MINIMAL || isLog(filename) || isProfile(filename);
}

private boolean isLog(String path) {
return TEST_LOG_PATTERN.matcher(path).matches()
|| BUILD_LOG_PATTERN.matcher(path).matches();
}

private boolean isProfile(PathMetadata path) {
return path.getPath().equals(profilePath);
private boolean isProfile(String path) {
return profilePath != null && path.equals(profilePath.getPathString());
}

private Single<List<PathMetadata>> queryRemoteCache(
Expand Down