@@ -844,12 +844,6 @@ private void injectRemoteArtifacts(RemoteAction action, ActionResultMetadata met
844
844
845
845
for (Map .Entry <Path , DirectoryMetadata > entry : metadata .directories ()) {
846
846
DirectoryMetadata directory = entry .getValue ();
847
- if (!directory .symlinks ().isEmpty ()) {
848
- throw new IOException (
849
- "Symlinks in action outputs are not yet supported by "
850
- + "--experimental_remote_download_outputs=minimal" );
851
- }
852
-
853
847
for (FileMetadata file : directory .files ()) {
854
848
remoteActionFileSystem .injectRemoteFile (
855
849
file .path ().asFragment (),
@@ -1082,7 +1076,8 @@ public InMemoryOutput downloadOutputs(RemoteAction action, RemoteActionResult re
1082
1076
1083
1077
ImmutableList .Builder <ListenableFuture <FileMetadata >> downloadsBuilder =
1084
1078
ImmutableList .builder ();
1085
- boolean downloadOutputs = shouldDownloadOutputsFor (result , metadata );
1079
+
1080
+ boolean downloadOutputs = shouldDownloadOutputsFor (result );
1086
1081
1087
1082
// Download into temporary paths, then move everything at the end.
1088
1083
// This avoids holding the output lock while downloading, which would prevent the local branch
@@ -1102,10 +1097,6 @@ public InMemoryOutput downloadOutputs(RemoteAction action, RemoteActionResult re
1102
1097
checkState (
1103
1098
result .getExitCode () == 0 ,
1104
1099
"injecting remote metadata is only supported for successful actions (exit code 0)." );
1105
- checkState (
1106
- metadata .symlinks .isEmpty (),
1107
- "Symlinks in action outputs are not yet supported by"
1108
- + " --remote_download_outputs=minimal" );
1109
1100
}
1110
1101
1111
1102
FileOutErr tmpOutErr = outErr .childOutErr ();
@@ -1139,31 +1130,6 @@ public InMemoryOutput downloadOutputs(RemoteAction action, RemoteActionResult re
1139
1130
1140
1131
if (downloadOutputs ) {
1141
1132
moveOutputsToFinalLocation (downloads , realToTmpPath );
1142
-
1143
- List <SymlinkMetadata > symlinksInDirectories = new ArrayList <>();
1144
- for (Entry <Path , DirectoryMetadata > entry : metadata .directories ()) {
1145
- for (SymlinkMetadata symlink : entry .getValue ().symlinks ()) {
1146
- // Symlinks should not be allowed inside directories because their semantics are unclear:
1147
- // tree artifacts are defined as a collection of regular files, and resolving the symlinks
1148
- // locally is asking for trouble. Sadly, we did start permitting relative symlinks at some
1149
- // point, so we can only ban the absolute ones.
1150
- // See https://github.com/bazelbuild/bazel/issues/16361.
1151
- if (symlink .target ().isAbsolute ()) {
1152
- throw new IOException (
1153
- String .format (
1154
- "Unsupported absolute symlink '%s' inside tree artifact '%s'" ,
1155
- symlink .path (), entry .getKey ()));
1156
- }
1157
- symlinksInDirectories .add (symlink );
1158
- }
1159
- }
1160
-
1161
- Iterable <SymlinkMetadata > symlinks =
1162
- Iterables .concat (metadata .symlinks (), symlinksInDirectories );
1163
-
1164
- // Create the symbolic links after all downloads are finished, because dangling symlinks
1165
- // might not be supported on all platforms.
1166
- createSymlinks (symlinks );
1167
1133
} else {
1168
1134
ActionInput inMemoryOutput = null ;
1169
1135
Digest inMemoryOutputDigest = null ;
@@ -1197,6 +1163,31 @@ public InMemoryOutput downloadOutputs(RemoteAction action, RemoteActionResult re
1197
1163
}
1198
1164
}
1199
1165
1166
+ List <SymlinkMetadata > symlinksInDirectories = new ArrayList <>();
1167
+ for (Entry <Path , DirectoryMetadata > entry : metadata .directories ()) {
1168
+ for (SymlinkMetadata symlink : entry .getValue ().symlinks ()) {
1169
+ // Symlinks should not be allowed inside directories because their semantics are unclear:
1170
+ // tree artifacts are defined as a collection of regular files, and resolving the symlinks
1171
+ // locally is asking for trouble. Sadly, we did start permitting relative symlinks at some
1172
+ // point, so we can only ban the absolute ones.
1173
+ // See https://github.com/bazelbuild/bazel/issues/16361.
1174
+ if (symlink .target ().isAbsolute ()) {
1175
+ throw new IOException (
1176
+ String .format (
1177
+ "Unsupported absolute symlink '%s' inside tree artifact '%s'" ,
1178
+ symlink .path (), entry .getKey ()));
1179
+ }
1180
+ symlinksInDirectories .add (symlink );
1181
+ }
1182
+ }
1183
+
1184
+ Iterable <SymlinkMetadata > symlinks =
1185
+ Iterables .concat (metadata .symlinks (), symlinksInDirectories );
1186
+
1187
+ // Create the symbolic links after all downloads are finished, because dangling symlinks
1188
+ // might not be supported on all platforms.
1189
+ createSymlinks (symlinks );
1190
+
1200
1191
if (result .success ()) {
1201
1192
// Check that all mandatory outputs are created.
1202
1193
for (ActionInput output : action .getSpawn ().getOutputFiles ()) {
@@ -1237,8 +1228,7 @@ public InMemoryOutput downloadOutputs(RemoteAction action, RemoteActionResult re
1237
1228
return null ;
1238
1229
}
1239
1230
1240
- private boolean shouldDownloadOutputsFor (
1241
- RemoteActionResult result , ActionResultMetadata metadata ) {
1231
+ private boolean shouldDownloadOutputsFor (RemoteActionResult result ) {
1242
1232
if (remoteOptions .remoteOutputsMode .downloadAllOutputs ()) {
1243
1233
return true ;
1244
1234
}
@@ -1247,16 +1237,6 @@ private boolean shouldDownloadOutputsFor(
1247
1237
if (result .getExitCode () != 0 ) {
1248
1238
return true ;
1249
1239
}
1250
- // Symlinks in actions output are not yet supported with BwoB.
1251
- if (!metadata .symlinks ().isEmpty ()) {
1252
- report (
1253
- Event .warn (
1254
- String .format (
1255
- "Symlinks in action outputs are not yet supported by --remote_download_minimal,"
1256
- + " falling back to downloading all action outputs due to output symlink %s" ,
1257
- Iterables .get (metadata .symlinks (), 0 ).path ())));
1258
- return true ;
1259
- }
1260
1240
return false ;
1261
1241
}
1262
1242
0 commit comments