Add better detection of mixed packs

This commit is contained in:
Alexander Weiss 2022-05-31 01:49:20 +02:00
parent 69f2082a41
commit cf1a8679bf
3 changed files with 11 additions and 2 deletions

View File

@ -40,7 +40,7 @@ impl Tree {
pub async fn from_backend(be: &impl IndexedBackend, id: Id) -> Result<Self> {
let data = be
.get_tree(&id)
.ok_or_else(|| anyhow!("blob not found in index"))?
.ok_or_else(|| anyhow!("blob {} not found in index", id.to_hex()))?
.read_data(be.be())
.await?;

View File

@ -42,11 +42,20 @@ async fn check_packs(be: &impl DecryptReadBackend) -> Result<IndexCollector> {
let mut process_pack = |p: IndexPack| {
packs.insert(p.id, p.pack_size());
let blob_type = p.blob_type();
// check offsests in index
let mut expected_offset: u32 = 0;
let mut blobs = p.blobs;
blobs.sort_unstable();
for blob in blobs {
if blob.tpe != blob_type {
eprintln!(
"pack {}: blob {} blob type does not match: {:?}, expected: {:?}",
p.id, blob.id, blob.tpe, blob_type
);
}
if blob.offset != expected_offset {
eprintln!(
"pack {}: blob {} offset in index: {}, expected: {}",

View File

@ -85,7 +85,7 @@ impl Extend<IndexPack> for IndexCollector {
length: blob.length,
uncompressed_length: blob.uncompressed_length,
};
match (p.blob_type(), &mut self.data) {
match (blob.tpe, &mut self.data) {
(BlobType::Tree, _) => self.tree.push(be),
(BlobType::Data, SortedHashSetMap::None) => {}
(BlobType::Data, SortedHashSetMap::Set(ids)) => ids.push(blob.id),