@@ -414,7 +414,7 @@ fn check_packs(
414414
415415 if let Some ( hot_be) = hot_be {
416416 let p = pb. progress_spinner ( "listing packs in hot repo..." ) ;
417- check_packs_list ( hot_be, tree_packs) ?;
417+ check_packs_list_hot ( hot_be, tree_packs, & packs ) ?;
418418 p. finish ( ) ;
419419 }
420420
@@ -456,6 +456,46 @@ fn check_packs_list(be: &impl ReadBackend, mut packs: HashMap<PackId, u32>) -> R
456456 Ok ( ( ) )
457457}
458458
459+ /// Checks if all packs in the backend are also in the index
460+ ///
461+ /// # Arguments
462+ ///
463+ /// * `be` - The backend to check
464+ /// * `packs` - The packs to check
465+ ///
466+ /// # Errors
467+ ///
468+ /// If a pack is missing or has a different size
469+ fn check_packs_list_hot (
470+ be : & impl ReadBackend ,
471+ mut treepacks : HashMap < PackId , u32 > ,
472+ packs : & HashMap < PackId , u32 > ,
473+ ) -> RusticResult < ( ) > {
474+ for ( id, size) in be
475+ . list_with_size ( FileType :: Pack )
476+ . map_err ( RusticErrorKind :: Backend ) ?
477+ {
478+ match treepacks. remove ( & PackId :: from ( id) ) {
479+ None => {
480+ if packs. contains_key ( & PackId :: from ( id) ) {
481+ warn ! ( "hot pack {id} is a data pack. This should not happen." ) ;
482+ } else {
483+ warn ! ( "hot pack {id} not referenced in index. Can be a parallel backup job. To repair: 'rustic repair index'." ) ;
484+ }
485+ }
486+ Some ( index_size) if index_size != size => {
487+ error ! ( "hot pack {id}: size computed by index: {index_size}, actual size: {size}. To repair: 'rustic repair index'." ) ;
488+ }
489+ _ => { } //everything ok
490+ }
491+ }
492+
493+ for ( id, _) in treepacks {
494+ error ! ( "tree pack {id} is referenced by the index but not present in hot repo! To repair: 'rustic repair index'." , ) ;
495+ }
496+ Ok ( ( ) )
497+ }
498+
459499/// Check if all snapshots and contained trees can be loaded and contents exist in the index
460500///
461501/// # Arguments
0 commit comments