Skip to content

Commit

Permalink
use fsync to flush metadata when reoperning a file with new headers
Browse files Browse the repository at this point in the history
  • Loading branch information
samoht committed Apr 27, 2021
1 parent 6a3794c commit e797fe9
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/unix/index_unix.ml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ module IO : Index.IO = struct
let header = { Raw.Header.offset; version; generation } in
Raw.Header.set raw header;
Raw.Fan.set raw "";
Raw.fsync raw;
raw

let clear ~generation ?(hook = fun () -> ()) t =
Expand Down Expand Up @@ -215,6 +216,7 @@ module IO : Index.IO = struct
Raw.Fan.set_size raw fan_size;
Raw.Version.set raw current_version;
Raw.Generation.set raw generation;
Raw.fsync raw;
v ~fan_size ~offset:Int63.zero raw)
else
let version = Raw.Version.get raw in
Expand Down

0 comments on commit e797fe9

Please sign in to comment.