mirror of https://github.com/dswd/zvault
Some changes
This commit is contained in:
parent
87f7cc0feb
commit
304dfe16e8
|
@ -22,7 +22,6 @@ dependencies = [
|
||||||
"rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"regex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"regex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rmp-serde 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rmp-serde 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-serialize 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"serde 0.9.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 0.9.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_utils 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_utils 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_yaml 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_yaml 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -316,11 +315,6 @@ dependencies = [
|
||||||
"serde 0.9.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 0.9.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustc-serialize"
|
|
||||||
version = "0.3.23"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "0.9.13"
|
version = "0.9.13"
|
||||||
|
@ -535,7 +529,6 @@ dependencies = [
|
||||||
"checksum regex-syntax 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9191b1f57603095f105d317e375d19b1c9c5c3185ea9633a99a6dcbed04457"
|
"checksum regex-syntax 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9191b1f57603095f105d317e375d19b1c9c5c3185ea9633a99a6dcbed04457"
|
||||||
"checksum rmp 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)" = "333f01365885cb192edaa22acb06d7e2f196bfd19d6969419e8b61307e0710ea"
|
"checksum rmp 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)" = "333f01365885cb192edaa22acb06d7e2f196bfd19d6969419e8b61307e0710ea"
|
||||||
"checksum rmp-serde 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f0b34c070f2a928d7786da44bfdb4372b547326bbc4757bd0696878558eac0bd"
|
"checksum rmp-serde 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f0b34c070f2a928d7786da44bfdb4372b547326bbc4757bd0696878558eac0bd"
|
||||||
"checksum rustc-serialize 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)" = "684ce48436d6465300c9ea783b6b14c4361d6b8dcbb1375b486a69cc19e2dfb0"
|
|
||||||
"checksum serde 0.9.13 (registry+https://github.com/rust-lang/crates.io-index)" = "231dfd55909400769e437326cfb4af8bec97c3dd56ab3d02df8ef5c7e00f179b"
|
"checksum serde 0.9.13 (registry+https://github.com/rust-lang/crates.io-index)" = "231dfd55909400769e437326cfb4af8bec97c3dd56ab3d02df8ef5c7e00f179b"
|
||||||
"checksum serde_utils 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b34a52969c7fc0254e214b82518c9a95dc88c84fc84cd847add314996a031be6"
|
"checksum serde_utils 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b34a52969c7fc0254e214b82518c9a95dc88c84fc84cd847add314996a031be6"
|
||||||
"checksum serde_yaml 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f8bd3f24ad8c7bcd34a6d70ba676dc11302b96f4f166aa5f947762e01098844d"
|
"checksum serde_yaml 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f8bd3f24ad8c7bcd34a6d70ba676dc11302b96f4f166aa5f947762e01098844d"
|
||||||
|
|
|
@ -13,7 +13,6 @@ squash-sys = "0.9"
|
||||||
quick-error = "1.1"
|
quick-error = "1.1"
|
||||||
blake2-rfc = "0.2"
|
blake2-rfc = "0.2"
|
||||||
murmurhash3 = "0.0.5"
|
murmurhash3 = "0.0.5"
|
||||||
rustc-serialize = "0.3"
|
|
||||||
chrono = "0.3"
|
chrono = "0.3"
|
||||||
clap = "2.23"
|
clap = "2.23"
|
||||||
log = "0.3"
|
log = "0.3"
|
||||||
|
|
|
@ -57,7 +57,7 @@ quick_error!{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn load_bundles(path: &Path, base: &Path, bundles: &mut HashMap<BundleId, StoredBundle>, crypto: Arc<Mutex<Crypto>>) -> Result<(Vec<StoredBundle>, Vec<StoredBundle>), BundleDbError> {
|
fn load_bundles(path: &Path, base: &Path, bundles: &mut HashMap<BundleId, StoredBundle>, crypto: Arc<Mutex<Crypto>>) -> Result<(Vec<StoredBundle>, Vec<StoredBundle>), BundleDbError> {
|
||||||
let mut paths = vec![path.to_path_buf()];
|
let mut paths = vec![path.to_path_buf()];
|
||||||
let mut bundle_paths = HashSet::new();
|
let mut bundle_paths = HashSet::new();
|
||||||
while let Some(path) = paths.pop() {
|
while let Some(path) = paths.pop() {
|
||||||
|
@ -158,14 +158,18 @@ impl BundleDb {
|
||||||
Ok((new, gone))
|
Ok((new, gone))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn save_cache(&self) -> Result<(), BundleDbError> {
|
pub fn flush(&mut self) -> Result<(), BundleDbError> {
|
||||||
|
self.finish_uploads().and_then(|()| self.save_cache())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn save_cache(&self) -> Result<(), BundleDbError> {
|
||||||
let bundles: Vec<_> = self.local_bundles.values().cloned().collect();
|
let bundles: Vec<_> = self.local_bundles.values().cloned().collect();
|
||||||
try!(StoredBundle::save_list_to(&bundles, &self.layout.local_bundle_cache_path()));
|
try!(StoredBundle::save_list_to(&bundles, &self.layout.local_bundle_cache_path()));
|
||||||
let bundles: Vec<_> = self.remote_bundles.values().cloned().collect();
|
let bundles: Vec<_> = self.remote_bundles.values().cloned().collect();
|
||||||
Ok(try!(StoredBundle::save_list_to(&bundles, &self.layout.remote_bundle_cache_path())))
|
Ok(try!(StoredBundle::save_list_to(&bundles, &self.layout.remote_bundle_cache_path())))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_cache(&mut self) -> Result<(), BundleDbError> {
|
fn update_cache(&mut self) -> Result<(), BundleDbError> {
|
||||||
let mut meta_bundles = HashSet::new();
|
let mut meta_bundles = HashSet::new();
|
||||||
for (id, bundle) in &self.remote_bundles {
|
for (id, bundle) in &self.remote_bundles {
|
||||||
if bundle.info.mode == BundleMode::Meta {
|
if bundle.info.mode == BundleMode::Meta {
|
||||||
|
@ -273,7 +277,7 @@ impl BundleDb {
|
||||||
Ok(bundle.info)
|
Ok(bundle.info)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn finish_uploads(&mut self) -> Result<(), BundleDbError> {
|
fn finish_uploads(&mut self) -> Result<(), BundleDbError> {
|
||||||
let mut uploader = None;
|
let mut uploader = None;
|
||||||
mem::swap(&mut self.uploader, &mut uploader);
|
mem::swap(&mut self.uploader, &mut uploader);
|
||||||
if let Some(uploader) = uploader {
|
if let Some(uploader) = uploader {
|
||||||
|
@ -343,6 +347,7 @@ impl BundleDb {
|
||||||
for id in ProgressIter::new("repairing bundles", to_repair.len(), to_repair.iter()) {
|
for id in ProgressIter::new("repairing bundles", to_repair.len(), to_repair.iter()) {
|
||||||
try!(self.repair_bundle(id.clone()));
|
try!(self.repair_bundle(id.clone()));
|
||||||
}
|
}
|
||||||
|
try!(self.flush());
|
||||||
}
|
}
|
||||||
Ok(!to_repair.is_empty())
|
Ok(!to_repair.is_empty())
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ impl Deserialize for BundleId {
|
||||||
|
|
||||||
impl BundleId {
|
impl BundleId {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn to_string(&self) -> String {
|
pub fn to_string(&self) -> String {
|
||||||
self.0.to_string()
|
self.0.to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ extern crate blake2_rfc as blake2;
|
||||||
extern crate murmurhash3;
|
extern crate murmurhash3;
|
||||||
extern crate serde_yaml;
|
extern crate serde_yaml;
|
||||||
#[macro_use] extern crate quick_error;
|
#[macro_use] extern crate quick_error;
|
||||||
extern crate rustc_serialize;
|
|
||||||
extern crate chrono;
|
extern crate chrono;
|
||||||
#[macro_use] extern crate clap;
|
#[macro_use] extern crate clap;
|
||||||
#[macro_use] extern crate log;
|
#[macro_use] extern crate log;
|
||||||
|
|
|
@ -409,7 +409,6 @@ impl Repository {
|
||||||
if try!(self.bundles.check(full, repair)) {
|
if try!(self.bundles.check(full, repair)) {
|
||||||
// Some bundles got repaired
|
// Some bundles got repaired
|
||||||
warn!("Some bundles have been rewritten, please remove the broken bundles manually.");
|
warn!("Some bundles have been rewritten, please remove the broken bundles manually.");
|
||||||
try!(self.bundles.finish_uploads());
|
|
||||||
try!(self.rebuild_bundle_map());
|
try!(self.rebuild_bundle_map());
|
||||||
try!(self.rebuild_index());
|
try!(self.rebuild_index());
|
||||||
}
|
}
|
||||||
|
|
|
@ -279,9 +279,8 @@ impl Repository {
|
||||||
}
|
}
|
||||||
self.next_meta_bundle = self.next_free_bundle_id()
|
self.next_meta_bundle = self.next_free_bundle_id()
|
||||||
}
|
}
|
||||||
try!(self.bundles.finish_uploads());
|
try!(self.bundles.flush());
|
||||||
try!(self.save_bundle_map());
|
try!(self.save_bundle_map());
|
||||||
try!(self.bundles.save_cache());
|
|
||||||
if !self.dirty && dirtyfile.exists() {
|
if !self.dirty && dirtyfile.exists() {
|
||||||
try!(fs::remove_file(&dirtyfile));
|
try!(fs::remove_file(&dirtyfile));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue