@@ -163,7 +163,8 @@ mod odb {
163
163
Unloaded ,
164
164
Loaded ( T ) ,
165
165
/// The file was loaded, but appeared to be missing on disk after reconciling our state with what's on disk.
166
- /// As there were handles that required pack-id stability we had to keep the pack.
166
+ /// As there were handles that required pack-id stability we had to keep the item to allow finding it on later
167
+ /// lookups.
167
168
Garbage ( T ) ,
168
169
/// File is missing on disk and could not be loaded when we tried or turned missing after reconciling our state.
169
170
Missing ,
@@ -322,16 +323,12 @@ mod odb {
322
323
} ) ;
323
324
load_indices:: Outcome :: Replace {
324
325
indices : todo ! ( ) ,
325
- mark : PackIndexMarker {
326
- generation : self . generation ,
327
- pack_index_sequence : self . files . len ( ) ,
328
- } ,
326
+ mark : self . marker ( ) ,
329
327
}
330
328
}
331
329
}
332
330
333
331
/// A way to indicate which pack indices we have seen already
334
- #[ derive( Copy , Clone ) ]
335
332
pub struct PackIndexMarker {
336
333
/// The generation the `pack_index_sequence` belongs to. Indices of different generations are completely incompatible.
337
334
pub ( crate ) generation : u8 ,
@@ -459,19 +456,21 @@ mod odb {
459
456
/// If the oid is known, just load indices again to continue
460
457
/// (objects rarely ever removed so should be present, maybe in another pack though),
461
458
/// and redo the entire lookup for a valid pack id whose pack can probably be loaded next time.
462
- /// The caller has to check the generation of the returned pack and compare it with their last generation,
463
- /// reloading the indices and retrying if it doesn't match.
464
459
pub ( crate ) fn load_pack (
465
460
& self ,
466
461
id : policy:: PackId ,
467
- ) -> std:: io:: Result < Option < ( PackIndexMarker , features:: OwnShared < git_pack:: data:: File > ) > > {
462
+ marker : PackIndexMarker ,
463
+ ) -> std:: io:: Result < Option < features:: OwnShared < git_pack:: data:: File > > > {
464
+ let state = get_ref_upgradeable ( & self . state ) ;
465
+ if state. generation != marker. generation {
466
+ return Ok ( None ) ;
467
+ }
468
468
match id. multipack_index {
469
469
None => {
470
- let state = get_ref_upgradeable ( & self . state ) ;
471
470
match state. files . get ( id. index ) {
472
471
Some ( f) => match f {
473
472
policy:: IndexAndPacks :: Index ( bundle) => match bundle. data . loaded ( ) {
474
- Some ( pack) => Ok ( Some ( ( state . marker ( ) , pack. clone ( ) ) ) ) ,
473
+ Some ( pack) => Ok ( Some ( pack. clone ( ) ) ) ,
475
474
None => {
476
475
let mut state = upgrade_ref_to_mut ( state) ;
477
476
let f = & mut state. files [ id. index ] ;
@@ -488,8 +487,7 @@ mod odb {
488
487
} ,
489
488
)
490
489
} ) ?
491
- . cloned ( )
492
- . map ( |f| ( state. marker ( ) , f) ) ) ,
490
+ . cloned ( ) ) ,
493
491
_ => unreachable ! ( ) ,
494
492
}
495
493
}
0 commit comments