Use swapfs #16
1 changed files with 6 additions and 2 deletions
|
@ -312,8 +312,12 @@ module Make
|
||||||
and sha512 = Ohex.encode Digestif.SHA512.(to_raw_string (get digests.sha512)) in
|
and sha512 = Ohex.encode Digestif.SHA512.(to_raw_string (get digests.sha512)) in
|
||||||
let dest = Mirage_kv.Key.v sha256 in
|
let dest = Mirage_kv.Key.v sha256 in
|
||||||
Logs.info (fun m -> m "downloaded %s, now writing" url);
|
Logs.info (fun m -> m "downloaded %s, now writing" url);
|
||||||
(Lwt.finalize (fun () -> set_from_handle t.dev dest swap)
|
let temp = Mirage_kv.Key.(v "pending" // dest) in
|
||||||
(fun () -> Swap.free swap))
|
Lwt_result.bind
|
||||||
|
(Lwt.finalize (fun () -> set_from_handle t.dev temp swap)
|
||||||
|
(fun () -> Swap.free swap))
|
||||||
|
(fun () -> KV.rename t.dev ~source:temp ~dest
|
||||||
|
|> Lwt_result.map_error (fun e -> `Write_error e))
|
||||||
>|= function
|
>|= function
|
||||||
| Ok () ->
|
| Ok () ->
|
||||||
remove_active url;
|
remove_active url;
|
||||||
|
|
Loading…
Reference in a new issue