Thanks to visit codestin.com
Credit goes to github.com

Skip to content

irmin-fs-unix configuration errors (Eio Backend) #2375

@patricoferris

Description

@patricoferris

There seems to be mishandling of the configuration values on the Irmin_fs_unix backend. In the lwt world, this was all handled directly via Irmin_fs.config root which set the root directory to root. Now, there is an indirection via Irmin_fs_unix.config ~path ~clock which sets up the Eio capabilities, but the root will default to ..

Unfortunately, this then breaks the file path handling inside the abstract Irmin_fs module, in particular, when listing directories. I think the following program would be very reasonable for someone to write, setting irmin-fs to use "irmin_example".

module Store = Irmin_fs_unix.KV.Make (Irmin.Contents.String)

let info () = Irmin.Info.Default.v ~message:"Commit" (Mtime_clock.now_ns ()) 

let main env =
  let conf = Irmin_fs_unix.conf ~path:Eio.Path.(env#fs / "irmin_example") ~clock:env#clock in 
  let repo = Store.Repo.v conf in
  let main = Store.main repo in
  Store.set_exn ~info main [ "a" ] "hello";
  let b1 = Store.of_branch repo "exp1" in
  Store.set_exn ~info b1 [ "a" ] "world";
  let branches = Store.Branch.list repo in
  Eio.traceln "Branches: [%a]\n%!" Fmt.(list ~sep:(Fmt.any ", ") string) branches

let () =
  Eio_main.run main

Which has the following output:

$ dune exec -- example/main.exe
+Branches: [xample/./refs/exp1, xample/./refs/main]

A small change is needed to get this working with this example in setting up the configuration.

let conf_unix = Irmin_fs_unix.conf ~path:env#fs ~clock:env#clock in
let conf_fs = Irmin_fs.config "irmin_example" in
let conf = Irmin.Backend.Conf.union conf_unix conf_fs in
...

I do not think this is very desirable. Instead, I think some more serious path hygiene is needed in Irmin_fs (or Irmin_fs_unix).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions