File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
gix-odb/src/store_impls/dynamic Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -99,17 +99,24 @@ impl Store {
9999 let mut db_paths = crate :: alternate:: resolve ( objects_dir. clone ( ) , & current_dir)
100100 . map_err ( |err| std:: io:: Error :: new ( std:: io:: ErrorKind :: Other , err) ) ?;
101101 db_paths. insert ( 0 , objects_dir. clone ( ) ) ;
102- let num_slots = super :: Store :: collect_indices_and_mtime_sorted_by_size ( db_paths, None , None )
102+ let num_slots = Store :: collect_indices_and_mtime_sorted_by_size ( db_paths, None , None )
103103 . map_err ( |err| std:: io:: Error :: new ( std:: io:: ErrorKind :: Other , err) ) ?
104104 . len ( ) ;
105105
106- ( ( num_slots as f32 * multiplier) as usize ) . max ( minimum)
106+ let candidate = ( ( num_slots as f32 * multiplier) as usize ) . max ( minimum) ;
107+ if candidate > crate :: store:: types:: PackId :: max_indices ( ) {
108+ // A chance for this to work without 10% extra allocation - this already
109+ // is an insane amount of packs.
110+ num_slots
111+ } else {
112+ candidate
113+ }
107114 }
108115 } ;
109116 if slot_count > crate :: store:: types:: PackId :: max_indices ( ) {
110117 return Err ( std:: io:: Error :: new (
111118 std:: io:: ErrorKind :: Other ,
112- "Cannot use more than 1 ^15 slots" ,
119+ format ! ( "Cannot use more than 2 ^15-1 slots, got {slot_count}" ) ,
113120 ) ) ;
114121 }
115122 let mut replacements: Vec < _ > = replacements. collect ( ) ;
You can’t perform that action at this time.
0 commit comments