Skip to content

Commit 46a4d4d

Browse files
committed
adapt to changes in gix-pack
1 parent 4b74996 commit 46a4d4d

File tree

4 files changed

+25
-8
lines changed

4 files changed

+25
-8
lines changed

gix-odb/src/store_impls/dynamic/find.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ pub(crate) mod error {
7575
}
7676
}
7777
pub use error::Error;
78+
use gix_features::zlib;
7879

7980
use crate::{store::types::PackId, Find};
8081

@@ -86,6 +87,7 @@ where
8687
&'b self,
8788
mut id: &'b gix_hash::oid,
8889
buffer: &'a mut Vec<u8>,
90+
inflate: &mut zlib::Inflate,
8991
pack_cache: &mut impl DecodeEntry,
9092
snapshot: &mut load_index::Snapshot,
9193
recursion: Option<error::DeltaBaseRecursion<'_>>,
@@ -147,6 +149,7 @@ where
147149
let res = match pack.decode_entry(
148150
entry,
149151
buffer,
152+
inflate,
150153
|id, _out| {
151154
index_file.pack_offset_by_id(id).map(|pack_offset| {
152155
gix_pack::data::decode::entry::ResolvedBase::InPack(pack.entry(pack_offset))
@@ -182,6 +185,7 @@ where
182185
.try_find_cached_inner(
183186
&base_id,
184187
&mut buf,
188+
inflate,
185189
pack_cache,
186190
snapshot,
187191
recursion
@@ -231,6 +235,7 @@ where
231235
pack.decode_entry(
232236
entry,
233237
buffer,
238+
inflate,
234239
|id, out| {
235240
index_file
236241
.pack_offset_by_id(id)
@@ -347,7 +352,8 @@ where
347352
) -> Result<Option<(gix_object::Data<'a>, Option<gix_pack::data::entry::Location>)>, Self::Error> {
348353
let id = id.as_ref();
349354
let mut snapshot = self.snapshot.borrow_mut();
350-
self.try_find_cached_inner(id, buffer, pack_cache, &mut snapshot, None)
355+
let mut inflate = self.inflate.borrow_mut();
356+
self.try_find_cached_inner(id, buffer, &mut inflate, pack_cache, &mut snapshot, None)
351357
}
352358

353359
fn location_by_oid(
@@ -364,6 +370,7 @@ where
364370

365371
let id = id.as_ref();
366372
let mut snapshot = self.snapshot.borrow_mut();
373+
let mut inflate = self.inflate.borrow_mut();
367374
'outer: loop {
368375
{
369376
let marker = snapshot.marker;
@@ -404,13 +411,14 @@ where
404411
buf.resize(entry.decompressed_size.try_into().expect("representable size"), 0);
405412
assert_eq!(pack.id, pack_id.to_intrinsic_pack_id(), "both ids must always match");
406413

407-
let res = pack.decompress_entry(&entry, buf).ok().map(|entry_size_past_header| {
408-
gix_pack::data::entry::Location {
414+
let res = pack
415+
.decompress_entry(&entry, &mut inflate, buf)
416+
.ok()
417+
.map(|entry_size_past_header| gix_pack::data::entry::Location {
409418
pack_id: pack.id,
410419
pack_offset,
411420
entry_size: entry.header_size() + entry_size_past_header,
412-
}
413-
});
421+
});
414422

415423
if idx != 0 {
416424
snapshot.indices.swap(0, idx);

gix-odb/src/store_impls/dynamic/handle.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ impl super::Store {
257257
refresh: RefreshMode::default(),
258258
ignore_replacements: false,
259259
token: Some(token),
260+
inflate: RefCell::new(Default::default()),
260261
snapshot: RefCell::new(self.collect_snapshot()),
261262
max_recursion_depth: Self::INITIAL_MAX_RECURSION_DEPTH,
262263
packed_object_count: Default::default(),
@@ -273,6 +274,7 @@ impl super::Store {
273274
refresh: Default::default(),
274275
ignore_replacements: false,
275276
token: Some(token),
277+
inflate: RefCell::new(Default::default()),
276278
snapshot: RefCell::new(self.collect_snapshot()),
277279
max_recursion_depth: Self::INITIAL_MAX_RECURSION_DEPTH,
278280
packed_object_count: Default::default(),
@@ -391,6 +393,7 @@ where
391393
}
392394
.into()
393395
},
396+
inflate: RefCell::new(Default::default()),
394397
snapshot: RefCell::new(self.store.collect_snapshot()),
395398
max_recursion_depth: self.max_recursion_depth,
396399
packed_object_count: Default::default(),

gix-odb/src/store_impls/dynamic/header.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use gix_features::zlib;
12
use std::ops::Deref;
23

34
use gix_hash::oid;
@@ -15,6 +16,7 @@ where
1516
fn try_header_inner<'b>(
1617
&'b self,
1718
mut id: &'b gix_hash::oid,
19+
inflate: &mut zlib::Inflate,
1820
snapshot: &mut load_index::Snapshot,
1921
recursion: Option<DeltaBaseRecursion<'_>>,
2022
) -> Result<Option<Header>, Error> {
@@ -71,7 +73,7 @@ where
7173
},
7274
};
7375
let entry = pack.entry(pack_offset);
74-
let res = match pack.decode_header(entry, |id| {
76+
let res = match pack.decode_header(entry, inflate, |id| {
7577
index_file.pack_offset_by_id(id).map(|pack_offset| {
7678
gix_pack::data::decode::header::ResolvedBase::InPack(pack.entry(pack_offset))
7779
})
@@ -85,6 +87,7 @@ where
8587
let hdr = self
8688
.try_header_inner(
8789
&base_id,
90+
inflate,
8891
snapshot,
8992
recursion
9093
.map(DeltaBaseRecursion::inc_depth)
@@ -127,7 +130,7 @@ where
127130
.as_ref()
128131
.expect("pack to still be available like just now");
129132
let entry = pack.entry(pack_offset);
130-
pack.decode_header(entry, |id| {
133+
pack.decode_header(entry, inflate, |id| {
131134
index_file
132135
.pack_offset_by_id(id)
133136
.map(|pack_offset| {
@@ -184,6 +187,7 @@ where
184187
fn try_header(&self, id: impl AsRef<oid>) -> Result<Option<Header>, Self::Error> {
185188
let id = id.as_ref();
186189
let mut snapshot = self.snapshot.borrow_mut();
187-
self.try_header_inner(id, &mut snapshot, None)
190+
let mut inflate = self.inflate.borrow_mut();
191+
self.try_header_inner(id, &mut inflate, &mut snapshot, None)
188192
}
189193
}

gix-odb/src/store_impls/dynamic/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! The standard object store which should fit all needs.
2+
use gix_features::zlib;
23
use std::{cell::RefCell, ops::Deref};
34

45
use crate::Store;
@@ -24,6 +25,7 @@ where
2425

2526
pub(crate) token: Option<handle::Mode>,
2627
snapshot: RefCell<load_index::Snapshot>,
28+
inflate: RefCell<zlib::Inflate>,
2729
packed_object_count: RefCell<Option<u64>>,
2830
}
2931

0 commit comments

Comments
 (0)