get_index now gets a new template parameter. Setting it to true will
make the index parsing less picky about missing important data. This
can be used to parse a partial index file.
---
builder/builder.ml | 2 +-
builder/index_parser.ml | 20 ++++++++++++++------
builder/index_parser.mli | 2 +-
3 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/builder/builder.ml b/builder/builder.ml
index e59c763b2..5802b6873 100644
--- a/builder/builder.ml
+++ b/builder/builder.ml
@@ -209,7 +209,7 @@ let main () =
~tmpdir in
match source.Sources.format with
| Sources.FormatNative ->
- Index_parser.get_index ~downloader ~sigchecker source
+ Index_parser.get_index ~downloader ~sigchecker ~template:false source
| Sources.FormatSimpleStreams ->
Simplestreams_parser.get_index ~downloader ~sigchecker source
) sources
diff --git a/builder/index_parser.ml b/builder/index_parser.ml
index 9b3daed24..3869123ed 100644
--- a/builder/index_parser.ml
+++ b/builder/index_parser.ml
@@ -24,7 +24,7 @@ open Utils
open Printf
open Unix
-let get_index ~downloader ~sigchecker
+let get_index ~downloader ~sigchecker ~template
{ Sources.uri = uri; proxy = proxy } =
let corrupt_file () =
error (f_"The index file downloaded from '%s' is corrupt.\nYou need to
ask the supplier of this file to fix it and upload a fixed version.") uri
@@ -112,7 +112,7 @@ let get_index ~downloader ~sigchecker
let revision =
try Rev_int (int_of_string (List.assoc ("revision", None) fields))
with
- | Not_found -> Rev_int 1
+ | Not_found -> if template then Rev_int 0 else Rev_int 1
| Failure _ ->
eprintf (f_"%s: cannot parse 'revision' field for
'%s'\n") prog n;
corrupt_file () in
@@ -122,11 +122,19 @@ let get_index ~downloader ~sigchecker
try Int64.of_string (List.assoc ("size", None) fields)
with
| Not_found ->
- eprintf (f_"%s: no 'size' field for '%s'\n") prog
n;
- corrupt_file ()
+ if template then
+ Int64.zero
+ else (
+ eprintf (f_"%s: no 'size' field for '%s'\n")
prog n;
+ corrupt_file ()
+ )
| Failure _ ->
- eprintf (f_"%s: cannot parse 'size' field for
'%s'\n") prog n;
- corrupt_file () in
+ if template then
+ Int64.zero
+ else (
+ eprintf (f_"%s: cannot parse 'size' field for
'%s'\n") prog n;
+ corrupt_file ()
+ ) in
let compressed_size =
try Some (Int64.of_string (List.assoc ("compressed_size", None)
fields))
with
diff --git a/builder/index_parser.mli b/builder/index_parser.mli
index 7c1c423ad..ae757ad6f 100644
--- a/builder/index_parser.mli
+++ b/builder/index_parser.mli
@@ -16,7 +16,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*)
-val get_index : downloader:Downloader.t -> sigchecker:Sigchecker.t ->
Sources.source -> Index.index
+val get_index : downloader:Downloader.t -> sigchecker:Sigchecker.t -> template:bool
-> Sources.source -> Index.index
(** [get_index download sigchecker source] will parse the source index file
into an index entry list. *)
--
2.11.0