Implement list function
This commit is contained in:
parent
ad09080ee6
commit
503bf47ccb
1 changed files with 16 additions and 3 deletions
|
@ -143,9 +143,22 @@ let get_partial t key ~offset ~length =
|
||||||
let l = min length (String.length data - offset) in
|
let l = min length (String.length data - offset) in
|
||||||
String.sub data offset l
|
String.sub data offset l
|
||||||
|
|
||||||
let list _t _key =
|
let list t key =
|
||||||
(* ((string * [`Value | `Dictionary]) list, error) result Lwt.t *)
|
let open Lwt.Infix in
|
||||||
assert false
|
match t.head with
|
||||||
|
| None -> Lwt.return (Error (`Not_found key))
|
||||||
|
| Some head ->
|
||||||
|
Search.find t.store head (`Path (Mirage_kv.Key.segments key)) >>= function
|
||||||
|
| None -> Lwt.return (Error (`Not_found key))
|
||||||
|
| Some tree ->
|
||||||
|
Store.read_exn t.store tree >>= function
|
||||||
|
| Tree t ->
|
||||||
|
Lwt_list.map_p (fun { Git.Tree.perm; name; _ } -> match perm with
|
||||||
|
| `Commit | `Dir -> Lwt.return (name, `Dictionary)
|
||||||
|
| `Everybody | `Exec | `Normal -> Lwt.return (name, `Value)
|
||||||
|
| `Link -> failwith "Unimplemented link follow")
|
||||||
|
(Store.Value.Tree.to_list t) >|= Result.ok
|
||||||
|
| _ -> Lwt.return (Error (`Dictionary_expected key))
|
||||||
|
|
||||||
let last_modified t key =
|
let last_modified t key =
|
||||||
let open Lwt.Infix in
|
let open Lwt.Infix in
|
||||||
|
|
Loading…
Reference in a new issue