Also setting repository dirty on crash

This commit is contained in:
Dennis Schwerdel 2017-04-12 10:34:36 +02:00
parent dc973c0313
commit 74e2417473
5 changed files with 13 additions and 4 deletions

View File

@ -232,7 +232,7 @@ impl Repository {
if self.dirty {
return Err(RepositoryError::Dirty)
}
self.dirty = true;
try!(self.set_dirty());
let reference_inode = reference.and_then(|b| self.get_inode(&b.root).ok());
let mut backup = Backup::default();
backup.config = self.config.clone();

View File

@ -64,7 +64,7 @@ impl Repository {
if self.dirty {
return Err(RepositoryError::Dirty)
}
self.dirty = true;
try!(self.set_dirty());
let mut usage = HashMap::new();
for (id, bundle) in self.bundle_map.bundles() {
let bundle = try!(self.bundles.get_bundle_info(&bundle).ok_or_else(|| IntegrityError::MissingBundle(bundle)));

View File

@ -217,6 +217,15 @@ impl Repository {
id
}
pub fn set_dirty(&mut self) -> Result<(), RepositoryError> {
self.dirty = true;
let dirtyfile = self.layout.dirtyfile_path();
if !dirtyfile.exists() {
try!(File::create(&dirtyfile));
}
Ok(())
}
pub fn flush(&mut self) -> Result<(), RepositoryError> {
let dirtyfile = self.layout.dirtyfile_path();
if self.dirty && !dirtyfile.exists() {

View File

@ -159,7 +159,7 @@ impl Repository {
if self.dirty {
return Err(RepositoryError::Dirty)
}
self.dirty = true;
try!(self.set_dirty());
let mut backup = Backup::default();
backup.config = self.config.clone();
backup.host = get_hostname().unwrap_or_else(|_| "".to_string());

View File

@ -21,7 +21,7 @@ impl Repository {
if self.dirty {
return Err(RepositoryError::Dirty)
}
self.dirty = true;
try!(self.set_dirty());
info!("Analyzing chunk usage");
let usage = try!(self.analyze_usage());
let mut data_total = 0;