pub fn repair(pwd: &str, storage: &mut Storage) -> Result<()> {
        let left_arm = Self::load_arm(0, pwd, storage);
        let right_arm = Self::load_arm(1, pwd, storage);

        match left_arm {
            Ok(mut left) => match right_arm {
                Ok(mut right) => {
                    if left.body.volume_id != right.body.volume_id
                        || left.body.key != right.body.key
                    {
                        return Err(Error::InvalidSuperBlk);
                    }
                    if left.body.seq > right.body.seq {
                        left.save(pwd, storage)?;
                    } else if left.body.seq < right.body.seq {
                        right.save(pwd, storage)?;
                    } else {
                        debug!("super block all good, no need repair");
                        return Ok(());
                    }
                }
                Err(_) => left.save(pwd, storage)?,
            },
            Err(err) => {
                if let Ok(mut right) = right_arm {
                    right.save(pwd, storage)?;
                } else {
                    return Err(err);
                }
            }
        }

        debug!("super block repaired");

        Ok(())
    }
// try to repair super block using at least one valid
try to repair super block using at least one valid
try to repair super block using at least one valid
pub fn repair(pwd: &str, storage: &mut Storage) -> Result<()> {
        let left_arm = Self::load_arm(0, pwd, storage);
        let right_arm = Self::load_arm(1, pwd, storage);
        match left_arm {
            Ok(mut left) => match right_arm {
                Ok(mut right) => {
                    if left.body.volume_id != right.body.volume_id
                        || left.body.key != right.body.key
                    {
                        return Err(Error::InvalidSuperBlk);
                    }
                    if left.body.seq > right.body.seq {
                        left.save(pwd, storage)?;
                    } else if left.body.seq < right.body.seq {
                        right.save(pwd, storage)?;
                    } else {
                        debug!("super block all good, no need repair");
                        return Ok(());
                    }
                }
                Err(_) => left.save(pwd, storage)?,
            },
            Err(err) => {
                if let Ok(mut right) = right_arm {
                    right.save(pwd, storage)?;
                } else {
                    return Err(err);
                }
            }
        }
        debug!("super block repaired");
        Ok(())
    }
pub fn repair ( pwd : & str , storage : & mut Storage ) -> Result < ( ) > { let left_arm = Self :: load_arm ( 0 , pwd , storage ) ; let right_arm = Self :: load_arm ( 1 , pwd , storage ) ; match left_arm { Ok ( mut left ) => match right_arm { Ok ( mut right ) => { if left . body . volume_id != right . body . volume_id || left . body . key != right . body . key { return Err ( Error :: InvalidSuperBlk ) ; } if left . body . seq > right . body . seq { left . save ( pwd , storage ) ? ; } else if left . body . seq < right . body . seq { right . save ( pwd , storage ) ? ; } else { debug ! ( " " ) ; return Ok ( ( ) ) ; } } Err ( _ ) => left . save ( pwd , storage ) ? , } , Err ( err ) => { if let Ok ( mut right ) = right_arm { right . save ( pwd , storage ) ? ; } else { return Err ( err ) ; } } } debug ! ( " " ) ; Ok ( ( ) ) }
try to repair super block using at least one valid
try to repair super block using at least one valid
pwd
&str
storage
&mut Storage
pwd
&str
storage
&mut Storage