Changeset 22 in code


Ignore:
Timestamp:
Nov 2, 2022, 9:47:20 PM (2 years ago)
Author:
fox
Message:

Use txt.conf to generate index.pck meta; fix double load while indexing

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/cli/index.ml

    r8 r22  
    6464
    6565let load dir =
     66        let kv = File_store.of_kv_file () in
    6667        let index_path = Filename.concat dir "index.pck" in
    67         let pck = match Header_pack.of_string @@ File_store.to_string index_path with
    68         | Error s -> failwith s | Ok pck -> pck
    69         | exception (Sys_error _) -> Header_pack.{
    70                 info = { version = version; id = Id.generate (); title = ""; people = []; locations = [] };
    71                 fields;
    72                 texts = of_text_list @@ File_store.fold ~dir
    73                         (fun a (t,_) -> of_text a t) [];
    74                 peers = Msgpck.of_list [];
    75         } in
    76         index { dir; index_path; pck }
     68        index { dir; index_path; pck = Header_pack.of_kv kv }
    7769
    7870open Cmdliner
  • trunk/cli/publish.ml

    r21 r22  
    1 let targets () =
    2         let kv = Logarion.File_store.of_kv_file () in
     1let targets kv =
    32        let pub_dir =
    43                try Logarion.Store.KV.find "Pubdir" kv with Not_found ->
     
    1413open Logarion
    1514let publish ids =
     15        let kv = Logarion.File_store.of_kv_file () in
    1616        let predicate t = List.mem t.Text.id ids in
    17         let targets = targets () in
     17        let targets = targets kv in
    1818        let pub_dirs = List.map (fun x -> snd x) targets in
    1919        File_store.iter ~predicate (fun (_t, p) ->
  • trunk/lib/header_pack.ml

    r7 r22  
    5454let of_string s = unpack @@ snd @@ Msgpck.StringBuf.read s
    5555
     56let of_kv kv =
     57        let find k kv = try Store.KV.find k kv with Not_found -> "" in
     58        let find_ls k kv = try String_set.list_of_csv (Store.KV.find k kv) with Not_found -> [] in
     59        {
     60                info = { version = version; id = find "Id" kv; title = find "Title" kv;
     61                        people = find_ls "Authors" kv; locations = find_ls "Locations" kv };
     62                fields;
     63                texts = Msgpck.List [];
     64                peers = str_list (find_ls "Peers" kv);
     65        }
     66
    5667let list filename = try
    5768        let texts_list = function
Note: See TracChangeset for help on using the changeset viewer.