mirror of https://github.com/dswd/zvault
Also setting repository dirty on crash
This commit is contained in:
parent
dc973c0313
commit
74e2417473
|
@ -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();
|
||||
|
|
|
@ -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)));
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue