Browse Source

Random bundle name

pull/10/head
Dennis Schwerdel 5 years ago committed by Dennis Schwerdel
parent
commit
f6862aa669
  1. 1
      Cargo.lock
  2. 1
      Cargo.toml
  3. 1
      README.md
  4. 4
      src/bundledb/db.rs
  5. 5
      src/bundledb/mod.rs
  6. 1
      src/main.rs

1
Cargo.lock generated

@ -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)",

1
Cargo.toml

@ -25,6 +25,7 @@ filetime = "0.1"
regex = "0.2"
fuse = "0.3"
lazy_static = "0.2"
rand = "0.3"
time = "*"
libc = "*"

1
README.md

@ -106,7 +106,6 @@ Recommended: Brotli/2-7
### Formats
- Bundles
- Encrypted bundle header
- Random bundle name
- Metadata
- Arbitrarily nested chunk lists

4
src/bundledb/db.rs

@ -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());

5
src/bundledb/mod.rs

@ -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 {

1
src/main.rs

@ -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…
Cancel
Save