Skip to content

Commit

Permalink
irmin-pack: Rewrite pack_store using dispatcher's accessor
Browse files Browse the repository at this point in the history
This commit is meant to better handle objects that are still live in
index but that have been GCed.
  • Loading branch information
Ngoguey42 committed Sep 6, 2022
1 parent 2d85ee9 commit c1cd0d7
Show file tree
Hide file tree
Showing 4 changed files with 207 additions and 212 deletions.
8 changes: 7 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@

- **irmin**
- Add `Storage` module for creating custom storage layers (#2047, @metanivek)

### Changed

### Fixed

- **irmin-pack**
- Fix the behaviour of irmin-pack regarding hashes and keys to GCed objects.
It used to not correctly ignore these entries, which could have resulted in
various bugs. E.g. the impossibility to append an object that used to be
dead and that has its hash in index. (#2070, @Ngoguey42)

## 3.4.0 (2022-08-25)

### Added
Expand Down
4 changes: 4 additions & 0 deletions src/irmin-pack/unix/dispatcher.ml
Original file line number Diff line number Diff line change
Expand Up @@ -240,4 +240,8 @@ module Make (Fm : File_manager.S with module Io = Io.Unix) :

let create_accessor_exn = Accessor.v_exn
let create_accessor_from_range_exn = Accessor.v_range_exn

let shrink_accessor_exn a ~new_len =
if new_len > a.len then failwith "shrink_accessor_exn to larger accessor";
{ a with len = new_len }
end
4 changes: 4 additions & 0 deletions src/irmin-pack/unix/dispatcher_intf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ module type S = sig
except that the precise length of the span will be decided during the
call. *)

val shrink_accessor_exn : accessor -> new_len:int -> accessor
(** [shrink_accessor_exn a ~new_len] is [a] where the length is smaller than
in [a].*)

val read_exn : t -> accessor -> bytes -> unit
(** [read_exn] either reads in the prefix or the suffix file, depending on
[accessor]. *)
Expand Down
Loading

0 comments on commit c1cd0d7

Please sign in to comment.