From 3c781cb3f9605176c915da825be877c70cfceb41 Mon Sep 17 00:00:00 2001 From: Louis Gesbert Date: Wed, 6 Oct 2021 18:27:38 +0200 Subject: [PATCH] fix(API): Fix listing exercise status when the status list hasn't been initialized; Fix #314 --- src/state/learnocaml_store.ml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/state/learnocaml_store.ml b/src/state/learnocaml_store.ml index 084becd2a..6e1ea61e9 100644 --- a/src/state/learnocaml_store.ml +++ b/src/state/learnocaml_store.ml @@ -203,7 +203,12 @@ module Exercise = struct List.iter (fun st -> Hashtbl.add tbl st.id st) l; tbl) @@ function - | Unix.Unix_error (Unix.ENOENT, _, _) -> Lwt.return tbl + | Unix.Unix_error (Unix.ENOENT, _, _) -> + Lazy.force !index >>= fun index -> + Exercise.Index.fold_exercises (fun () id _ -> + Hashtbl.add tbl id (Exercise.Status.default id)) + () index; + Lwt.return tbl | e -> Lwt.fail e )