Skip to content

Commit

Permalink
Fix dump-data-json
Browse files Browse the repository at this point in the history
  • Loading branch information
ushitora-anqou committed Sep 27, 2023
1 parent 0a50e8b commit d722be8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions lib/verifier.ml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ let verify_balanced_transactions pool =
|> Printf.sprintf "Unbalanced transactions:\n%s")
else Ok ()

let verify_notes pool notes =
let verify_notes ?(print = true) pool notes =
Datastore.use pool @@ fun con ->
try
notes
Expand All @@ -46,7 +46,7 @@ let verify_notes pool notes =
match Datastore.(query (prepare con sql) []) with
| Error msg -> failwithf "Error !show: %s\n" msg
| Ok [] | Ok [ [ Null ] ] -> ()
| Ok [ [ Text s ] ] -> Printf.printf "%s\n" s
| Ok [ [ Text s ] ] -> if print then Printf.printf "%s\n" s
| _ -> failwithf "Error !show: invalid result:\n%s" sql)
| Assert sql -> (
match Datastore.(query (prepare con sql) []) with
Expand All @@ -57,8 +57,8 @@ let verify_notes pool notes =
Ok ()
with Failure s -> Error s

let verify pool notes =
let verify ?print pool notes =
let ( let* ) = Lwt_result.bind in
let* () = verify_balanced_transactions pool in
let* () = verify_notes pool notes in
let* () = verify_notes ?print pool notes in
Lwt.return_ok ()
2 changes: 1 addition & 1 deletion lib/web_server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ let generate in_filename thn err =
try%lwt
let%lwt m, notes = Loader.load_file in_filename in
Sql_writer.with_dump_file m @@ fun pool ->
match%lwt Verifier.verify pool notes with
match%lwt Verifier.verify ~print:false pool notes with
| Error s -> failwithf "Verification error: %s" s
| Ok () ->
Lwt.finalize (fun () -> thn pool) (fun () -> Datastore.close_db pool)
Expand Down

0 comments on commit d722be8

Please sign in to comment.