1717import me .itzg .helpers .errors .GenericException ;
1818import me .itzg .helpers .errors .InvalidParameterException ;
1919import me .itzg .helpers .files .Manifests ;
20+ import me .itzg .helpers .http .FailedRequestException ;
2021import me .itzg .helpers .http .Fetch ;
2122import me .itzg .helpers .http .SharedFetch ;
2223import me .itzg .helpers .http .Uris ;
@@ -62,6 +63,9 @@ public class MulitCopyCommand implements Callable<Integer> {
6263 @ Option (names = "--skip-existing" , defaultValue = "false" )
6364 boolean skipExisting ;
6465
66+ @ Option (names = "--ignore-missing-sources" , description = "Don't log or fail exit code when any or all sources are missing" )
67+ boolean ignoreMissingSources ;
68+
6569 @ Parameters (split = SPLIT_COMMA_NL , splitSynopsisLabel = SPLIT_SYNOPSIS_COMMA_NL , arity = "1..*" ,
6670 paramLabel = "SRC" ,
6771 description = "Any mix of source file, directory, or URLs."
@@ -228,9 +232,9 @@ private Mono<Path> processRemoteSource(String source) {
228232 .toDirectory (dest )
229233 .skipUpToDate (skipUpToDate )
230234 .skipExisting (skipExisting )
231- .handleDownloaded ((downloaded , uri , size ) -> {
232- log .debug ("Downloaded {} from {} ({} bytes)" , downloaded , uri , size );
233- } )
235+ .handleDownloaded ((downloaded , uri , size ) ->
236+ log .debug ("Downloaded {} from {} ({} bytes)" , downloaded , uri , size )
237+ )
234238 .handleStatus ((status , uri , file ) -> {
235239 switch (status ) {
236240 case DOWNLOADING :
@@ -247,6 +251,9 @@ private Mono<Path> processRemoteSource(String source) {
247251 }
248252 })
249253 .assemble ()
254+ .onErrorResume (throwable -> ignoreMissingSources && FailedRequestException .isNotFound (throwable ),
255+ throwable -> Mono .empty ()
256+ )
250257 .checkpoint ("Retrieving " + source , true );
251258 }
252259
0 commit comments