From 1ad24b103fc3ab3f234c8f6ae3019730eda4c549 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 19 Oct 2016 22:57:09 +0100 Subject: api query: Provide ability to tolerate 404 This is useful for backward-compatibility with earlier ftpmaster api versions. Signed-off-by: Ian Jackson --- dgit | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'dgit') diff --git a/dgit b/dgit index 6d9baca..97cd684 100755 --- a/dgit +++ b/dgit @@ -1009,9 +1009,9 @@ sub archive_api_query_cmd ($) { return @cmd; } -sub api_query ($$) { +sub api_query ($$;$) { use JSON; - my ($data, $subpath) = @_; + my ($data, $subpath, $ok404) = @_; badcfg "ftpmasterapi archive query method takes no data part" if length $data; my @cmd = archive_api_query_cmd($subpath); @@ -1023,6 +1023,7 @@ sub api_query ($$) { fail "curl failed to print 3-digit HTTP code"; } my $code = $&; + return undef if $code eq '404' && $ok404; fail "fetch of $url gave HTTP code $code" unless $url =~ m#^file://# or $code =~ m/^2/; return decode_json($json); -- cgit v1.2.3