mirror of
https://github.com/rustic-rs/rustic.git
synced 2025-10-26 11:18:51 +00:00
Add better detection of mixed packs
This commit is contained in:
parent
69f2082a41
commit
cf1a8679bf
@ -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?;
|
||||
|
||||
|
||||
@ -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: {}",
|
||||
|
||||
@ -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),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user