Skip to content

Commit a773854

Browse files
committed
fix: improve error message for when there is too many packs.
Affects jj-vcs/jj#6906
1 parent 45b369c commit a773854

File tree

1 file changed

+10
-3
lines changed
  • gix-odb/src/store_impls/dynamic

1 file changed

+10
-3
lines changed

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff 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();

0 commit comments

Comments
 (0)