Changeset 31 in code for trunk/lib/peers.ml
- Timestamp:
- Nov 18, 2022, 1:41:55 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.