mirror of https://github.com/dswd/zvault
Handling the case of broken backup roots (re #3)
This commit is contained in:
parent
14ec763fd0
commit
3576d4c34f
|
@ -176,12 +176,19 @@ impl Repository {
|
||||||
};
|
};
|
||||||
info!("Checking backup...");
|
info!("Checking backup...");
|
||||||
let mut checked = Bitmap::new(self.index.capacity());
|
let mut checked = Bitmap::new(self.index.capacity());
|
||||||
if let Some(chunks) = try!(self.check_subtree(Path::new("").to_path_buf(), &backup.root, &mut checked, repair)) {
|
match self.check_subtree(Path::new("").to_path_buf(), &backup.root, &mut checked, repair) {
|
||||||
try!(self.flush());
|
Ok(None) => (),
|
||||||
backup.root = chunks;
|
Ok(Some(chunks)) => {
|
||||||
backup.modified = true;
|
try!(self.flush());
|
||||||
try!(self.evacuate_broken_backup(&name));
|
backup.root = chunks;
|
||||||
try!(self.save_backup(&backup, &name));
|
backup.modified = true;
|
||||||
|
try!(self.evacuate_broken_backup(&name));
|
||||||
|
try!(self.save_backup(&backup, &name));
|
||||||
|
},
|
||||||
|
Err(err) => {
|
||||||
|
warn!("The root of the backup {} has been corrupted\n\tcaused by: {}", name, err);
|
||||||
|
try!(self.evacuate_broken_backup(&name));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -265,12 +272,19 @@ impl Repository {
|
||||||
};
|
};
|
||||||
for (name, mut backup) in ProgressIter::new("ckecking backups", backup_map.len(), backup_map.into_iter()) {
|
for (name, mut backup) in ProgressIter::new("ckecking backups", backup_map.len(), backup_map.into_iter()) {
|
||||||
let path = format!("{}::", name);
|
let path = format!("{}::", name);
|
||||||
if let Some(chunks) = try!(self.check_subtree(Path::new(&path).to_path_buf(), &backup.root, &mut checked, repair)) {
|
match self.check_subtree(Path::new(&path).to_path_buf(), &backup.root, &mut checked, repair) {
|
||||||
try!(self.flush());
|
Ok(None) => (),
|
||||||
backup.root = chunks;
|
Ok(Some(chunks)) => {
|
||||||
backup.modified = true;
|
try!(self.flush());
|
||||||
try!(self.evacuate_broken_backup(&name));
|
backup.root = chunks;
|
||||||
try!(self.save_backup(&backup, &name));
|
backup.modified = true;
|
||||||
|
try!(self.evacuate_broken_backup(&name));
|
||||||
|
try!(self.save_backup(&backup, &name));
|
||||||
|
},
|
||||||
|
Err(err) => {
|
||||||
|
warn!("The root of the backup {} has been corrupted\n\tcaused by: {}", name, err);
|
||||||
|
try!(self.evacuate_broken_backup(&name));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in New Issue