@@ -866,12 +866,6 @@ private void injectRemoteArtifacts(
866
866
867
867
for (Map .Entry <Path , DirectoryMetadata > entry : metadata .directories ()) {
868
868
DirectoryMetadata directory = entry .getValue ();
869
- if (!directory .symlinks ().isEmpty ()) {
870
- throw new IOException (
871
- "Symlinks in action outputs are not yet supported by "
872
- + "--experimental_remote_download_outputs=minimal" );
873
- }
874
-
875
869
for (FileMetadata file : directory .files ()) {
876
870
remoteActionFileSystem .injectRemoteFile (
877
871
file .path ().asFragment (),
@@ -1162,7 +1156,8 @@ public InMemoryOutput downloadOutputs(RemoteAction action, RemoteActionResult re
1162
1156
1163
1157
ImmutableList .Builder <ListenableFuture <FileMetadata >> downloadsBuilder =
1164
1158
ImmutableList .builder ();
1165
- boolean downloadOutputs = shouldDownloadOutputsFor (action , result , metadata );
1159
+
1160
+ boolean downloadOutputs = shouldDownloadOutputsFor (action , result );
1166
1161
1167
1162
// Download into temporary paths, then move everything at the end.
1168
1163
// This avoids holding the output lock while downloading, which would prevent the local branch
@@ -1182,10 +1177,6 @@ public InMemoryOutput downloadOutputs(RemoteAction action, RemoteActionResult re
1182
1177
checkState (
1183
1178
result .getExitCode () == 0 ,
1184
1179
"injecting remote metadata is only supported for successful actions (exit code 0)." );
1185
- checkState (
1186
- metadata .symlinks .isEmpty (),
1187
- "Symlinks in action outputs are not yet supported by"
1188
- + " --remote_download_outputs=minimal" );
1189
1180
}
1190
1181
1191
1182
FileOutErr tmpOutErr = outErr .childOutErr ();
@@ -1219,38 +1210,6 @@ public InMemoryOutput downloadOutputs(RemoteAction action, RemoteActionResult re
1219
1210
1220
1211
if (downloadOutputs ) {
1221
1212
moveOutputsToFinalLocation (downloads , realToTmpPath );
1222
-
1223
- List <SymlinkMetadata > symlinksInDirectories = new ArrayList <>();
1224
- for (Entry <Path , DirectoryMetadata > entry : metadata .directories ()) {
1225
- for (SymlinkMetadata symlink : entry .getValue ().symlinks ()) {
1226
- // Symlinks should not be allowed inside directories because their semantics are unclear:
1227
- // tree artifacts are defined as a collection of regular files, and resolving a remotely
1228
- // produced symlink against the local filesystem is asking for trouble.
1229
- //
1230
- // Sadly, we started permitting relative symlinks at some point, so we have to allow them
1231
- // until the --incompatible_remote_disallow_symlink_in_tree_artifact flag is flipped.
1232
- // Absolute symlinks, on the other hand, have never been allowed.
1233
- //
1234
- // See also https://github.com/bazelbuild/bazel/issues/16361 for potential future work
1235
- // to allow *unresolved* symlinks in a tree artifact.
1236
- boolean isAbsolute = symlink .target ().isAbsolute ();
1237
- if (remoteOptions .incompatibleRemoteDisallowSymlinkInTreeArtifact || isAbsolute ) {
1238
- throw new IOException (
1239
- String .format (
1240
- "Unsupported symlink '%s' inside tree artifact '%s'" ,
1241
- symlink .path ().relativeTo (entry .getKey ()),
1242
- entry .getKey ().relativeTo (execRoot )));
1243
- }
1244
- symlinksInDirectories .add (symlink );
1245
- }
1246
- }
1247
-
1248
- Iterable <SymlinkMetadata > symlinks =
1249
- Iterables .concat (metadata .symlinks (), symlinksInDirectories );
1250
-
1251
- // Create the symbolic links after all downloads are finished, because dangling symlinks
1252
- // might not be supported on all platforms.
1253
- createSymlinks (symlinks );
1254
1213
} else {
1255
1214
ActionInput inMemoryOutput = null ;
1256
1215
Digest inMemoryOutputDigest = null ;
@@ -1285,6 +1244,37 @@ public InMemoryOutput downloadOutputs(RemoteAction action, RemoteActionResult re
1285
1244
}
1286
1245
}
1287
1246
1247
+ List <SymlinkMetadata > symlinksInDirectories = new ArrayList <>();
1248
+ for (Entry <Path , DirectoryMetadata > entry : metadata .directories ()) {
1249
+ for (SymlinkMetadata symlink : entry .getValue ().symlinks ()) {
1250
+ // Symlinks should not be allowed inside directories because their semantics are unclear:
1251
+ // tree artifacts are defined as a collection of regular files, and resolving a remotely
1252
+ // produced symlink against the local filesystem is asking for trouble.
1253
+ //
1254
+ // Sadly, we started permitting relative symlinks at some point, so we have to allow them
1255
+ // until the --incompatible_remote_disallow_symlink_in_tree_artifact flag is flipped.
1256
+ // Absolute symlinks, on the other hand, have never been allowed.
1257
+ //
1258
+ // See also https://github.com/bazelbuild/bazel/issues/16361 for potential future work
1259
+ // to allow *unresolved* symlinks in a tree artifact.
1260
+ boolean isAbsolute = symlink .target ().isAbsolute ();
1261
+ if (remoteOptions .incompatibleRemoteDisallowSymlinkInTreeArtifact || isAbsolute ) {
1262
+ throw new IOException (
1263
+ String .format (
1264
+ "Unsupported symlink '%s' inside tree artifact '%s'" ,
1265
+ symlink .path ().relativeTo (entry .getKey ()), entry .getKey ().relativeTo (execRoot )));
1266
+ }
1267
+ symlinksInDirectories .add (symlink );
1268
+ }
1269
+ }
1270
+
1271
+ Iterable <SymlinkMetadata > symlinks =
1272
+ Iterables .concat (metadata .symlinks (), symlinksInDirectories );
1273
+
1274
+ // Create the symbolic links after all downloads are finished, because dangling symlinks
1275
+ // might not be supported on all platforms.
1276
+ createSymlinks (symlinks );
1277
+
1288
1278
if (result .success ()) {
1289
1279
// Check that all mandatory outputs are created.
1290
1280
for (ActionInput output : action .getSpawn ().getOutputFiles ()) {
@@ -1325,8 +1315,7 @@ public InMemoryOutput downloadOutputs(RemoteAction action, RemoteActionResult re
1325
1315
return null ;
1326
1316
}
1327
1317
1328
- private boolean shouldDownloadOutputsFor (
1329
- RemoteAction action , RemoteActionResult result , ActionResultMetadata metadata ) {
1318
+ private boolean shouldDownloadOutputsFor (RemoteAction action , RemoteActionResult result ) {
1330
1319
if (remoteOptions .remoteOutputsMode .downloadAllOutputs ()) {
1331
1320
return true ;
1332
1321
}
@@ -1335,16 +1324,6 @@ private boolean shouldDownloadOutputsFor(
1335
1324
if (result .getExitCode () != 0 ) {
1336
1325
return true ;
1337
1326
}
1338
- // Symlinks in actions output are not yet supported with BwoB.
1339
- if (!metadata .symlinks ().isEmpty ()) {
1340
- report (
1341
- Event .warn (
1342
- String .format (
1343
- "Symlinks in action outputs are not yet supported by --remote_download_minimal,"
1344
- + " falling back to downloading all action outputs due to output symlink %s" ,
1345
- Iterables .get (metadata .symlinks (), 0 ).path ())));
1346
- return true ;
1347
- }
1348
1327
1349
1328
checkNotNull (remoteOutputChecker , "remoteOutputChecker must not be null" );
1350
1329
for (var output : action .getSpawn ().getOutputFiles ()) {
0 commit comments