- Timestamp:
- Nov 18, 2022, 1:41:55 PM (2 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cli/dune
r25 r31 2 2 (name txt) 3 3 (public_name txt) 4 (modules txt authors convert conversion edit file index last listing new topics html atom gemini publish pull read recent) 4 (modules txt authors convert conversion edit file index last listing 5 new topics html atom gemini peers publish pull read recent) 5 6 (libraries text_parse.converter text_parse.parsers logarion msgpck curl str cmdliner)) -
trunk/cli/pull.ml
r30 r31 87 87 then pull_text url dir id 88 88 89 (*TODO: integrate in lib*) 89 90 let validate_id_length s = String.length s <= 32 90 91 91 let validate_id_chars s = try 92 92 String.iter (function 'a'..'z'|'A'..'Z'|'0'..'9'-> () | _ -> raise (Invalid_argument "")) s; … … 95 95 96 96 let pull_index url authors_opt topics_opt = 97 let index_url = url ^ "/index.pck" in97 let index_url = Filename.concat url "index.pck" in 98 98 match curl_pull index_url with 99 99 | Error s -> prerr_endline s; false … … 128 128 let pull got_one peer_url = if got_one then got_one else 129 129 (pull_index peer_url auths topics) in 130 Logarion.Peers.fold pull false; 130 let fold_locations init peer = 131 ignore @@ List.fold_left pull init peer.Logarion.Peers.locations; 132 false 133 in 134 ignore @@ Logarion.Peers.fold fold_locations false; 131 135 Curl.global_cleanup () 132 136 -
trunk/cli/txt.ml
r25 r31 16 16 Listing.term; 17 17 New.term; 18 Peers.term; 18 19 Publish.term; 19 20 Pull.term; -
trunk/lib/peers.ml
r21 r31 1 1 let text_dir = Filename.concat (File_store.txtdir ()) "peers" 2 2 3 type t = { path: string; locations: string list } 4 3 5 let fold fn init = match Sys.readdir text_dir with 4 | exception (Sys_error msg) -> prerr_endline msg 6 | exception (Sys_error msg) -> prerr_endline msg; init 5 7 | dirs -> 6 let read_pack path = 7 let pack_path = Filename.(concat text_dir @@ concat path "index.pck") in 8 match Sys.file_exists pack_path with false -> () | true -> 9 match Header_pack.of_string (File_store.to_string pack_path) with 10 | Error s -> Printf.eprintf "%s %s\n" s pack_path 11 | Ok p -> ignore @@ List.fold_left fn init Header_pack.(p.info.locations) 8 let read_pack init path = 9 let fullpath = Filename.concat text_dir path in 10 if Sys.is_directory fullpath then begin 11 let pack_path = Filename.concat fullpath "index.pck" in 12 match Sys.file_exists pack_path with 13 | false -> Printf.eprintf "Missing index.pck for %s\n" path; init 14 | true -> match Header_pack.of_string (File_store.to_string pack_path) with 15 | Error s -> Printf.eprintf "%s %s\n" s pack_path; init 16 | Ok p -> fn init { path; locations = Header_pack.(p.info.locations) } 17 end else init 12 18 in 13 Array. iter read_packdirs19 Array.fold_left read_pack init dirs 14 20 15 21 let scheme url =
Note:
See TracChangeset
for help on using the changeset viewer.