mirror of https://github.com/dswd/zvault
Random bundle name
This commit is contained in:
parent
727f59b2d3
commit
f6862aa669
|
@ -16,6 +16,7 @@ dependencies = [
|
|||
"murmurhash3 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quick-error 1.1.0 (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)",
|
||||
"rmp-serde 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
|
@ -25,6 +25,7 @@ filetime = "0.1"
|
|||
regex = "0.2"
|
||||
fuse = "0.3"
|
||||
lazy_static = "0.2"
|
||||
rand = "0.3"
|
||||
time = "*"
|
||||
libc = "*"
|
||||
|
||||
|
|
|
@ -106,7 +106,6 @@ Recommended: Brotli/2-7
|
|||
### Formats
|
||||
- Bundles
|
||||
- Encrypted bundle header
|
||||
- Random bundle name
|
||||
- Metadata
|
||||
- Arbitrarily nested chunk lists
|
||||
|
||||
|
|
|
@ -255,11 +255,11 @@ impl BundleDb {
|
|||
#[inline]
|
||||
pub fn add_bundle(&mut self, bundle: BundleWriter) -> Result<BundleInfo, BundleDbError> {
|
||||
let bundle = try!(bundle.finish(&self));
|
||||
let id = bundle.id();
|
||||
let random_id = BundleId::random();
|
||||
if bundle.info.mode == BundleMode::Meta {
|
||||
try!(self.copy_remote_bundle_to_cache(&bundle))
|
||||
}
|
||||
let (folder, filename) = bundle_path(&id, self.remote_path.clone(), self.remote_bundles.len());
|
||||
let (folder, filename) = bundle_path(&random_id, self.remote_path.clone(), self.remote_bundles.len());
|
||||
try!(fs::create_dir_all(&folder).context(&folder as &Path));
|
||||
let bundle = try!(bundle.move_to(folder.join(filename)));
|
||||
self.remote_bundles.insert(bundle.id(), bundle.clone());
|
||||
|
|
|
@ -12,6 +12,7 @@ use ::prelude::*;
|
|||
|
||||
use std::fmt;
|
||||
use serde;
|
||||
use rand;
|
||||
|
||||
|
||||
pub static HEADER_STRING: [u8; 7] = *b"zvault\x01";
|
||||
|
@ -39,6 +40,10 @@ impl BundleId {
|
|||
fn to_string(&self) -> String {
|
||||
self.0.to_string()
|
||||
}
|
||||
|
||||
pub fn random() -> Self {
|
||||
BundleId(Hash{high: rand::random(), low: rand::random()})
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for BundleId {
|
||||
|
|
|
@ -19,6 +19,7 @@ extern crate filetime;
|
|||
extern crate regex;
|
||||
#[macro_use] extern crate lazy_static;
|
||||
extern crate fuse;
|
||||
extern crate rand;
|
||||
extern crate time;
|
||||
extern crate libc;
|
||||
|
||||
|
|
Loading…
Reference in New Issue