Skip to content

Commit e8e8509

Browse files
committed
mcopy: provide option to ignore missing remote sources
1 parent 6b8cbbe commit e8e8509

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/main/java/me/itzg/helpers/sync/MulitCopyCommand.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import me.itzg.helpers.errors.GenericException;
1818
import me.itzg.helpers.errors.InvalidParameterException;
1919
import me.itzg.helpers.files.Manifests;
20+
import me.itzg.helpers.http.FailedRequestException;
2021
import me.itzg.helpers.http.Fetch;
2122
import me.itzg.helpers.http.SharedFetch;
2223
import 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

Comments
 (0)