@@ -38,9 +38,9 @@ let rec rdecons = function
3838 | [] -> None
3939 | [ x ] -> Some ([] , x)
4040 | x :: xs -> (
41- match rdecons xs with
42- | None -> None
43- | Some (xs , leaf ) -> Some (x :: xs, leaf) )
41+ match rdecons xs with
42+ | None -> None
43+ | Some (xs , leaf ) -> Some (x :: xs, leaf) )
4444
4545let ok x = Lwt. return (Ok x)
4646
@@ -119,7 +119,7 @@ module Make (P9p : Protocol_9p.Client.S) = struct
119119 type t = {
120120 read : unit -> Cstruct .t result ;
121121 mutable buffer : string ;
122- mutable eof : bool
122+ mutable eof : bool ;
123123 }
124124
125125 let create read = { buffer = " " ; read; eof = false }
@@ -161,14 +161,14 @@ module Make (P9p : Protocol_9p.Client.S) = struct
161161 match String. cut ~sep: " " line with
162162 | None -> err " missing space"
163163 | Some (op , path ) -> (
164- match Path. of_string path with
165- | Error e -> err e
166- | Ok path -> (
167- match op with
168- | "+" -> `Added path :: acc
169- | "-" -> `Removed path :: acc
170- | "*" -> `Updated path :: acc
171- | e -> err e ) ) )
164+ match Path. of_string path with
165+ | Error e -> err e
166+ | Ok path -> (
167+ match op with
168+ | "+" -> `Added path :: acc
169+ | "-" -> `Removed path :: acc
170+ | "*" -> `Updated path :: acc
171+ | e -> err e ) ))
172172 [] lines
173173 |> ok
174174 with Err e -> bug " %s" e
@@ -181,7 +181,8 @@ module Make (P9p : Protocol_9p.Client.S) = struct
181181 let with_file_full t path fn =
182182 P9p. with_fid t.conn (fun newfid ->
183183 P9p. walk_from_root t.conn newfid path > |= wrap_9p >> *= fn newfid
184- > |= fun x -> Ok x )
184+ > |= fun x ->
185+ Ok x)
185186 > |= function
186187 | Ok x -> x (* Error or success from [fn] *)
187188 | Error _ as e -> wrap_9p e
@@ -223,38 +224,39 @@ module Make (P9p : Protocol_9p.Client.S) = struct
223224 > |= wrap_9p
224225 >> *= fun _open ->
225226 write_to_fid t fid ~offset: 0L data > |= wrap_9p >> *= fun _resp ->
226- ok () )
227+ ok () )
227228
228229 let create_symlink t ~dir leaf target =
229230 Log. debug (fun f ->
230- f " create_symlink %a -> %s" pp_path (dir / leaf) target );
231+ f " create_symlink %a -> %s" pp_path (dir / leaf) target);
231232 with_file t dir (fun fid ->
232233 P9p.LowLevel. create ~extension: target t.conn fid leaf symlink
233234 Protocol_9p.Types.OpenMode. write_only
234235 > |= wrap_9p
235- >> *= fun _resp -> ok () )
236+ >> *= fun _resp ->
237+ ok () )
236238
237239 let replace_file t path leaf data =
238240 Log. debug (fun f ->
239241 f " replace_file %a -> %S" pp_path (path / leaf)
240- (Cstruct. to_string data) );
242+ (Cstruct. to_string data));
241243 with_file t (path / leaf) (fun fid ->
242244 P9p.LowLevel. update ~length: 0L t.conn fid > |= wrap_9p >> *= fun () ->
243245 P9p.LowLevel. openfid t.conn fid Protocol_9p.Types.OpenMode. write_only
244246 > |= wrap_9p
245247 >> *= fun _open ->
246248 write_to_fid t fid ~offset: 0L data > |= wrap_9p >> *= fun _resp ->
247- ok () )
249+ ok () )
248250
249251 let write_stream t path data =
250252 Log. debug (fun f ->
251- f " write %S to %a" (Cstruct. to_string data) pp_path path );
253+ f " write %S to %a" (Cstruct. to_string data) pp_path path);
252254 with_file t path (fun fid ->
253255 P9p.LowLevel. openfid t.conn fid Protocol_9p.Types.OpenMode. write_only
254256 > |= wrap_9p
255257 >> *= fun _open ->
256258 write_to_fid t fid ~offset: 0L data > |= wrap_9p >> *= fun _resp ->
257- ok () )
259+ ok () )
258260
259261 (* TODO: limited to 2 GB files *)
260262 let read_all t path =
@@ -270,7 +272,7 @@ module Make (P9p : Protocol_9p.Client.S) = struct
270272 let truncate t path new_length =
271273 Log. debug (fun f -> f " truncate %a to %Ld" pp_path path new_length);
272274 with_file t path (fun fid ->
273- P9p.LowLevel. update t.conn ~length: new_length fid > |= wrap_9p )
275+ P9p.LowLevel. update t.conn ~length: new_length fid > |= wrap_9p)
274276
275277 let read_node_aux ~link ~file ~dir t path =
276278 let open Protocol_9p.Types in
@@ -280,12 +282,15 @@ module Make (P9p : Protocol_9p.Client.S) = struct
280282 | Some qid when List. mem Qid. Symlink qid.Qid. flags -> link t path
281283 | Some qid when not (List. mem Qid. Directory qid.Qid. flags) ->
282284 file t path
283- | _ -> dir t path )
285+ | _ -> dir t path)
284286
285287 let read_link_aux t path =
286- read_all t path >> *= fun data -> ok (`Link (Cstruct. to_string data))
288+ read_all t path >> *= fun data ->
289+ ok (`Link (Cstruct. to_string data))
287290
288- let read_file_aux t path = read_all t path >> *= fun data -> ok (`File data)
291+ let read_file_aux t path =
292+ read_all t path >> *= fun data ->
293+ ok (`File data)
289294
290295 let read_dir_aux t path =
291296 P9p. readdir t.conn path > |= wrap_9p >> *= fun items ->
@@ -300,17 +305,20 @@ module Make (P9p : Protocol_9p.Client.S) = struct
300305 let read_link t path =
301306 let err _ _ = Lwt. return (Error `Not_symlink ) in
302307 read_node_aux ~link: read_link_aux ~file: err ~dir: err t path
303- > |*= fun (`Link l ) -> l
308+ > |*= fun (`Link l ) ->
309+ l
304310
305311 let read_file t path =
306312 let err _ _ = Lwt. return (Error `Not_file ) in
307313 read_node_aux ~link: err ~file: read_file_aux ~dir: err t path
308- > |*= fun (`File l ) -> l
314+ > |*= fun (`File l ) ->
315+ l
309316
310317 let read_dir t path =
311318 let err _ _ = Lwt. return (Error `Not_dir ) in
312319 read_node_aux ~link: err ~file: err ~dir: read_dir_aux t path
313- > |*= fun (`Dir l ) -> l
320+ > |*= fun (`Dir l ) ->
321+ l
314322
315323 let stat t path =
316324 P9p. stat t.conn path > |= wrap_9p >> = function
@@ -342,7 +350,7 @@ module Make (P9p : Protocol_9p.Client.S) = struct
342350 Log. debug (fun f -> f " set_executable %a to %b" pp_path path exec);
343351 let mode = if exec then rwxr_xr_x else rw_r__r__ in
344352 with_file t path (fun fid ->
345- P9p.LowLevel. update t.conn ~mode fid > |= wrap_9p )
353+ P9p.LowLevel. update t.conn ~mode fid > |= wrap_9p)
346354
347355 let random_subdir t parent =
348356 let rec aux = function
@@ -377,7 +385,7 @@ module Make (P9p : Protocol_9p.Client.S) = struct
377385 let th = ref (next () ) in
378386 Lwt_switch. add_hook_or_exec switch (fun () ->
379387 Lwt. cancel ! th;
380- Lwt. return () )
388+ Lwt. return () )
381389 >> = fun () ->
382390 let rec loop () =
383391 abort_if_off switch @@ fun () ->
@@ -392,15 +400,17 @@ module Make (P9p : Protocol_9p.Client.S) = struct
392400 loop () )
393401 in
394402 Lwt. catch loop (function
395- | Lwt. Canceled as ex -> abort_if_off switch @@ fun () -> Lwt. fail ex
396- | ex -> Lwt. fail ex )
403+ | Lwt. Canceled as ex ->
404+ abort_if_off switch @@ fun () ->
405+ Lwt. fail ex
406+ | ex -> Lwt. fail ex)
397407
398408 (* Ensure that [base @ path] exists (assuming that [base] already exists). *)
399409 let make_dirs t ~base path =
400410 let path = Path. unwrap path in
401411 let rec aux user_path =
402412 Log. debug (fun f ->
403- f " make_dirs.aux(%a)" (Fmt.Dump. list String. dump) user_path );
413+ f " make_dirs.aux(%a)" (Fmt.Dump. list String. dump) user_path);
404414 match rdecons user_path with
405415 | None -> ok ()
406416 | Some (dir , leaf ) -> (
@@ -432,7 +442,7 @@ module Make (P9p : Protocol_9p.Client.S) = struct
432442 fs : FS .t ;
433443 path : string list ;
434444 reads : value cache ;
435- stats : stat option cache
445+ stats : stat option cache ;
436446 }
437447
438448 let find_cache c p = try Some (Path.Map. find p ! c) with Not_found -> None
@@ -588,13 +598,13 @@ module Make (P9p : Protocol_9p.Client.S) = struct
588598 let rec aux = function
589599 | [] -> Ok []
590600 | x :: xs -> (
591- match Path. of_string x with
592- | Error e ->
593- Error (`Internal (Fmt. strf " Invalid path in conflicts: %s" e))
594- | Ok path -> (
595- match aux xs with
596- | Error _ as e -> e
597- | Ok paths -> Ok (path :: paths) ) )
601+ match Path. of_string x with
602+ | Error e ->
603+ Error (`Internal (Fmt. strf " Invalid path in conflicts: %s" e))
604+ | Ok path -> (
605+ match aux xs with
606+ | Error _ as e -> e
607+ | Ok paths -> Ok (path :: paths) ) )
598608 in
599609 Lwt. return (aux paths)
600610
@@ -627,9 +637,9 @@ module Make (P9p : Protocol_9p.Client.S) = struct
627637 >> = function
628638 | Error e ->
629639 Log. err (fun f ->
630- f " Error aborting transaction %a: %a" pp_path t.path pp_error e
631- );
640+ f " Error aborting transaction %a: %a" pp_path t.path pp_error e);
632641 t.closed < - true ;
642+
633643 (* Give up *)
634644 Lwt. return (Ok () )
635645 | Ok () ->
@@ -677,7 +687,8 @@ module Make (P9p : Protocol_9p.Client.S) = struct
677687 let create fs name =
678688 (* Note: DataKit returns success if the branch already exists too,
679689 so no need to handle errors here. *)
680- FS. create_dir fs ~dir: [ " branch" ] name > |*= fun () -> { fs; name }
690+ FS. create_dir fs ~dir: [ " branch" ] name > |*= fun () ->
691+ { fs; name }
681692
682693 let remove t = FS. remove t.fs (branch_dir t)
683694
@@ -735,20 +746,20 @@ module Make (P9p : Protocol_9p.Client.S) = struct
735746 (* Make sure the user doesn't think their transaction succeeded *)
736747 failwith
737748 " Transaction returned Ok without committing or aborting (so \
738- forced abort)" )
749+ forced abort)" )
739750 (fun () ->
740751 if tr.Transaction. closed then Lwt. return ()
741752 else (
742753 (* Just log, so we don't hide the underlying error *)
743754 Log. info (fun f ->
744755 f
745756 " Transaction finished without committing or aborting (will \
746- abort)" );
757+ abort)" );
747758 Transaction. abort tr > |= function
748759 | Ok () -> ()
749760 | Error e ->
750761 Fmt. kstrf failwith " error while aborting the transaction: %a"
751- pp_error e ) )
762+ pp_error e ))
752763 end
753764
754765 let branch t name = Branch. create t name
@@ -770,12 +781,12 @@ module Make (P9p : Protocol_9p.Client.S) = struct
770781 >> *= fun () ->
771782 FS. read_all t (path / " head" ) >> *= fun commit_id ->
772783 let id = String. trim (Cstruct. to_string commit_id) in
773- ok { Commit. fs = t; id } )
784+ ok { Commit. fs = t; id })
774785 (fun () ->
775786 FS. remove t path > |= function
776787 | Error e ->
777788 Log. err (fun f -> f " Error removing remote %S: %a" id pp_error e)
778- | Ok () -> () )
789+ | Ok () -> () )
779790
780791 let commit t id : Commit.t result =
781792 FS. read_all t ([ " commits" ] / id) >> *= fun _json ->
@@ -785,7 +796,9 @@ module Make (P9p : Protocol_9p.Client.S) = struct
785796
786797 let connect conn = { FS. conn }
787798
788- let disconnect t = P9p. disconnect t.FS. conn > |= fun () -> Ok ()
799+ let disconnect t =
800+ P9p. disconnect t.FS. conn > |= fun () ->
801+ Ok ()
789802
790803 type t = FS .t
791804end
0 commit comments