Cache invalidation

This commit is contained in:
Reynir Björnsson 2020-12-07 21:20:24 +01:00
parent 8b143ab062
commit 17b0107ffe

View file

@ -45,15 +45,21 @@ let read_full t path run =
Bos.OS.File.read f >>= fun s -> Bos.OS.File.read f >>= fun s ->
Builder.Asn.exec_of_cs (Cstruct.of_string s) Builder.Asn.exec_of_cs (Cstruct.of_string s)
>>| fun (job_info, uuid, out, start, finish, result, data) -> >>| fun (job_info, uuid, out, start, finish, result, data) ->
{ meta = { job_info; uuid; start; finish; result }; let meta = { job_info; uuid; start; finish; result } in
out; data } t.cache <- RunMap.add (path, run) meta t.cache;
{ meta; out; data }
let read_full_meta t path run = let read_full_meta t path run =
match RunMap.find_opt (path, run) t.cache with match RunMap.find_opt (path, run) t.cache with
| Some meta -> Ok meta | Some meta ->
Bos.OS.File.exists Fpath.(t.dir // path // run / "full") >>= fun exists ->
if exists
then Ok meta
else
(t.cache <- RunMap.remove (path, run) t.cache;
Error (`Msg "no such file"))
| None -> | None ->
read_full t path run >>| fun { meta; out = _; data = _ } -> read_full t path run >>| fun { meta; out = _; data = _ } ->
t.cache <- RunMap.add (path, run) meta t.cache;
meta meta
let job t job = let job t job =