diff options
author | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2016-10-19 22:57:09 +0100 |
---|---|---|
committer | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2016-10-30 16:35:58 +0000 |
commit | 1ad24b103fc3ab3f234c8f6ae3019730eda4c549 (patch) | |
tree | b68d7462751485f269a9b3c88b7211bb5760f54d | |
parent | 0026f041d9735826170c8fa568e32f04c0d4ca12 (diff) |
api query: Provide ability to tolerate 404
This is useful for backward-compatibility with earlier ftpmaster api
versions.
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
-rwxr-xr-x | dgit | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -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); |