Skip to content

Commit

Permalink
Merge pull request #294 from talex5/windows
Browse files Browse the repository at this point in the history
Fix Windows CI
  • Loading branch information
talex5 authored Nov 26, 2024
2 parents 2e01348 + c888957 commit bcaeda8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Use OCaml ${{ matrix.ocaml-compiler }}
uses: ocaml/setup-ocaml@v3
Expand Down
2 changes: 1 addition & 1 deletion capnp-rpc-unix.opam
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ depends: [
"mirage-crypto-rng-eio" {>= "1.1.0" & with-test}
"mdx" {>= "2.4.1" & with-test}
"eio_main" {with-test}
"eio" {>= "1.1"}
"eio" {>= "1.2"}
]
conflicts: [
"jbuilder"
Expand Down
2 changes: 1 addition & 1 deletion capnp-rpc.opam
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ depends: [
"conf-capnproto" {build}
"capnp" {>= "3.6.0"}
"stdint" {>= "0.6.0"}
"eio" {>= "1.1"}
"eio" {>= "1.2"}
"astring"
"fmt" {>= "0.8.7"}
"logs"
Expand Down
7 changes: 5 additions & 2 deletions unix/file_store.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ open Capnp_rpc

module ReaderOps = Capnp.Runtime.ReaderInc.Make(Capnp_rpc)

let on_windows = Sys.os_type = "Win32"

let ( / ) = Eio.Path.( / )

type 'a t = {
Expand All @@ -19,15 +21,16 @@ let segments_of_reader = function

let save t ~digest data =
let leaf = leaf_of_digest digest in
let tmp_leaf = leaf ^ ".new" in
let tmp_leaf = if on_windows then leaf else leaf ^ ".new" in
Eio.Path.with_open_out ~create:(`Or_truncate 0o644) (t.dir / tmp_leaf) (fun flow ->
let segments = segments_of_reader data in
segments |> List.iter (fun {Message.segment; bytes_consumed} ->
let buf = Cstruct.of_bytes segment ~len:bytes_consumed in
Eio.Flow.write flow [buf]
);
);
Eio.Path.rename (t.dir / tmp_leaf) (t.dir / leaf)
if not on_windows then
Eio.Path.rename (t.dir / tmp_leaf) (t.dir / leaf)

let remove t ~digest =
Eio.Path.unlink (t.dir / leaf_of_digest digest)
Expand Down

0 comments on commit bcaeda8

Please sign in to comment.