When URL absent, fetch peers in peers.txt
This commit is contained in:
parent
6cb3c2ef88
commit
3bdfa78b0b
11
http/http.ml
11
http/http.ml
@ -73,7 +73,7 @@ let parse_index _is_selected fn url = function
|
||||
in List.iteri of_pck texts)
|
||||
| _ -> prerr_endline "malformed feed"
|
||||
|
||||
let pull url _authors _keywords _topics =
|
||||
let pull_index url _authors _keywords _topics =
|
||||
let index_url = Uri.of_string (url ^ "/index.pck") in
|
||||
match http_apply response index_url with
|
||||
| Error msg -> prerr_endline @@ "Failed index request for " ^ url ^ " " ^ msg
|
||||
@ -87,6 +87,15 @@ let pull url _authors _keywords _topics =
|
||||
let is_selected text = List.fold_left (fun a e -> a && e text) true [](*predicates*) in
|
||||
parse_index is_selected pull_text (Uri.of_string url) pack
|
||||
|
||||
let pull_list_indices auths words topics =
|
||||
match open_in "peers.txt" with
|
||||
| exception (Sys_error msg) -> prerr_endline msg
|
||||
| file ->
|
||||
let rec read () = try pull_index (input_line file) auths words topics; read () with End_of_file -> () in
|
||||
read ()
|
||||
|
||||
let pull = function | "" -> pull_list_indices | x -> pull_index x
|
||||
|
||||
open Cmdliner
|
||||
|
||||
let pull_term =
|
||||
|
Loading…
x
Reference in New Issue
Block a user