mirror of https://github.com/dswd/zvault
No longer clobbering broken files (re #14)
This commit is contained in:
parent
150278a560
commit
bd23aac64c
|
@ -15,6 +15,7 @@ This project follows [semantic versioning](http://semver.org).
|
|||
* [fixed] Only repairing backups with --repair
|
||||
* [fixed] Fixed vacuum
|
||||
* [fixed] First removing bundles, then adding new ones
|
||||
* [fixed] No longer clobbering broken files
|
||||
|
||||
|
||||
### v0.2.0 (2017-04-14)
|
||||
|
|
|
@ -348,9 +348,15 @@ impl BundleDb {
|
|||
}
|
||||
|
||||
fn evacuate_broken_bundle(&mut self, mut bundle: StoredBundle) -> Result<(), BundleDbError> {
|
||||
let new_path = self.layout.base_path().join(bundle.path.with_extension("bundle.broken"));
|
||||
warn!("Moving bundle to {:?}", new_path);
|
||||
try!(bundle.move_to(self.layout.base_path(), new_path));
|
||||
let src = self.layout.base_path().join(&bundle.path);
|
||||
let mut dst = src.with_extension("bundle.broken");
|
||||
let mut num = 1;
|
||||
while dst.exists() {
|
||||
dst = src.with_extension(&format!("bundle.{}.broken", num));
|
||||
num += 1;
|
||||
}
|
||||
warn!("Moving bundle to {:?}", dst);
|
||||
try!(bundle.move_to(self.layout.base_path(), dst));
|
||||
self.remote_bundles.remove(&bundle.info.id);
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -159,7 +159,12 @@ impl Repository {
|
|||
fn evacuate_broken_backup(&self, name: &str) -> Result<(), RepositoryError> {
|
||||
warn!("The backup {} was corrupted and needed to be modified.", name);
|
||||
let src = self.layout.backup_path(name);
|
||||
let dst = src.with_extension("backup.broken");
|
||||
let mut dst = src.with_extension("backup.broken");
|
||||
let mut num = 1;
|
||||
while dst.exists() {
|
||||
dst = src.with_extension(&format!("backup.{}.broken", num));
|
||||
num += 1;
|
||||
}
|
||||
if fs::rename(&src, &dst).is_err() {
|
||||
try!(fs::copy(&src, &dst));
|
||||
try!(fs::remove_file(&src));
|
||||
|
|
Loading…
Reference in New Issue