Introduce 'peers' subcommand, refactor in pull

git-svn-id: file:///srv/svn/repo/kosuzu/trunk@31 eb64cd80-c68d-6f47-b6a3-0ada418499da
This commit is contained in:
fox
2022-11-18 13:41:55 +00:00
parent 777a1c8aee
commit 215cd434ef
5 changed files with 61 additions and 12 deletions

View File

@@ -86,15 +86,15 @@ let per_text url dir filter print i id time title authors topics = match id with
|| Person.Set.exists (fun t -> List.mem (Person.to_string t) authors) filter.authors)
then pull_text url dir id
(*TODO: integrate in lib*)
let validate_id_length s = String.length s <= 32
let validate_id_chars s = try
String.iter (function 'a'..'z'|'A'..'Z'|'0'..'9'-> () | _ -> raise (Invalid_argument "")) s;
true
with Invalid_argument _ -> false
let pull_index url authors_opt topics_opt =
let index_url = url ^ "/index.pck" in
let index_url = Filename.concat url "index.pck" in
match curl_pull index_url with
| Error s -> prerr_endline s; false
| Ok body ->
@@ -127,7 +127,11 @@ let pull_list auths topics =
Curl.global_init Curl.CURLINIT_GLOBALALL;
let pull got_one peer_url = if got_one then got_one else
(pull_index peer_url auths topics) in
Logarion.Peers.fold pull false;
let fold_locations init peer =
ignore @@ List.fold_left pull init peer.Logarion.Peers.locations;
false
in
ignore @@ Logarion.Peers.fold fold_locations false;
Curl.global_cleanup ()
let pull url auths topics = match url with