mirror of https://github.com/dswd/zvault
Making clippy happy again
This commit is contained in:
parent
d3e74d6b7f
commit
db7c6ef4fb
|
@ -23,7 +23,7 @@ dependencies = [
|
|||
"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)",
|
||||
"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.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_yaml 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sodiumoxide 0.0.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"squash-sys 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -322,7 +322,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
|
||||
[[package]]
|
||||
name = "serde_utils"
|
||||
version = "0.5.1"
|
||||
version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"serde 0.9.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -530,7 +530,7 @@ dependencies = [
|
|||
"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 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.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c6fbfe71b80337654f81dfc667315ed6908e9303972bf719aacc919d491af0db"
|
||||
"checksum serde_yaml 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f8bd3f24ad8c7bcd34a6d70ba676dc11302b96f4f166aa5f947762e01098844d"
|
||||
"checksum sodiumoxide 0.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "bc02c0bc77ffed8e8eaef004399b825cf4fd8aa02d0af6e473225affd583ff4d"
|
||||
"checksum squash-sys 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "db1f9dde91d819b7746e153bc32489fa19e6a106c3d7f2b92187a4efbdc88b40"
|
||||
|
|
|
@ -8,7 +8,7 @@ description = "Deduplicating backup tool"
|
|||
serde = "0.9"
|
||||
rmp-serde = "0.12"
|
||||
serde_yaml = "0.6"
|
||||
serde_utils = "0.5.1"
|
||||
serde_utils = "0.5.2"
|
||||
squash-sys = "0.9"
|
||||
quick-error = "1.1"
|
||||
blake2-rfc = "0.2"
|
||||
|
|
|
@ -255,13 +255,13 @@ impl BundleDb {
|
|||
let id = bundle.id();
|
||||
let (folder, filename) = self.layout.local_bundle_path(&id, self.local_bundles.len());
|
||||
try!(fs::create_dir_all(&folder).context(&folder as &Path));
|
||||
let bundle = try!(bundle.copy_to(&self.layout.base_path(), folder.join(filename)));
|
||||
let bundle = try!(bundle.copy_to(self.layout.base_path(), folder.join(filename)));
|
||||
self.local_bundles.insert(id, bundle);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn add_bundle(&mut self, bundle: BundleWriter) -> Result<BundleInfo, BundleDbError> {
|
||||
let mut bundle = try!(bundle.finish(&self));
|
||||
let mut bundle = try!(bundle.finish(self));
|
||||
if bundle.info.mode == BundleMode::Meta {
|
||||
try!(self.copy_remote_bundle_to_cache(&bundle))
|
||||
}
|
||||
|
@ -288,7 +288,7 @@ impl BundleDb {
|
|||
}
|
||||
|
||||
pub fn get_chunk_list(&self, bundle: &BundleId) -> Result<ChunkList, BundleDbError> {
|
||||
let mut bundle = try!(self.get_stored_bundle(bundle).and_then(|stored| self.get_bundle(&stored)));
|
||||
let mut bundle = try!(self.get_stored_bundle(bundle).and_then(|stored| self.get_bundle(stored)));
|
||||
Ok(try!(bundle.get_chunk_list()).clone())
|
||||
}
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ impl BundleReader {
|
|||
info_data.resize(header.info_size, 0);
|
||||
try!(file.read_exact(&mut info_data).context(path));
|
||||
if let Some(ref encryption) = header.encryption {
|
||||
info_data = try!(crypto.lock().unwrap().decrypt(&encryption, &info_data).context(path));
|
||||
info_data = try!(crypto.lock().unwrap().decrypt(encryption, &info_data).context(path));
|
||||
}
|
||||
let mut info: BundleInfo = try!(msgpack::decode(&info_data).context(path));
|
||||
info.encryption = header.encryption;
|
||||
|
@ -131,7 +131,7 @@ impl BundleReader {
|
|||
chunk_data.resize(self.info.chunk_list_size, 0);
|
||||
try!(file.read_exact(&mut chunk_data).context(&self.path as &Path));
|
||||
if let Some(ref encryption) = self.info.encryption {
|
||||
chunk_data = try!(self.crypto.lock().unwrap().decrypt(&encryption, &chunk_data).context(&self.path as &Path));
|
||||
chunk_data = try!(self.crypto.lock().unwrap().decrypt(encryption, &chunk_data).context(&self.path as &Path));
|
||||
}
|
||||
let chunks = ChunkList::read_from(&chunk_data);
|
||||
let mut chunk_positions = Vec::with_capacity(chunks.len());
|
||||
|
@ -164,7 +164,7 @@ impl BundleReader {
|
|||
|
||||
fn decode_contents(&self, mut data: Vec<u8>) -> Result<Vec<u8>, BundleReaderError> {
|
||||
if let Some(ref encryption) = self.info.encryption {
|
||||
data = try!(self.crypto.lock().unwrap().decrypt(&encryption, &data).context(&self.path as &Path));
|
||||
data = try!(self.crypto.lock().unwrap().decrypt(encryption, &data).context(&self.path as &Path));
|
||||
}
|
||||
if let Some(ref compression) = self.info.compression {
|
||||
let mut stream = try!(compression.decompress_stream().context(&self.path as &Path));
|
||||
|
|
|
@ -76,7 +76,7 @@ impl BundleUploader {
|
|||
self.waiting.fetch_sub(1, Ordering::SeqCst);
|
||||
self.wait.0.notify_all();
|
||||
let folder = dst_path.parent().unwrap();
|
||||
try!(fs::create_dir_all(&folder).context(&folder as &Path));
|
||||
try!(fs::create_dir_all(&folder).context(folder as &Path));
|
||||
try!(fs::copy(&src_path, &dst_path).context(&dst_path as &Path));
|
||||
try!(fs::remove_file(&src_path).context(&src_path as &Path));
|
||||
debug!("Uploaded {:?} to {:?}", src_path, dst_path);
|
||||
|
|
|
@ -94,14 +94,14 @@ impl BundleWriter {
|
|||
try!(stream.finish(&mut self.data).map_err(BundleWriterError::Compression))
|
||||
}
|
||||
if let Some(ref encryption) = self.encryption {
|
||||
self.data = try!(self.crypto.lock().unwrap().encrypt(&encryption, &self.data));
|
||||
self.data = try!(self.crypto.lock().unwrap().encrypt(encryption, &self.data));
|
||||
}
|
||||
let encoded_size = self.data.len();
|
||||
let mut chunk_data = Vec::with_capacity(self.chunks.encoded_size());
|
||||
self.chunks.write_to(&mut chunk_data).unwrap();
|
||||
let id = BundleId(self.hash_method.hash(&chunk_data));
|
||||
if let Some(ref encryption) = self.encryption {
|
||||
chunk_data = try!(self.crypto.lock().unwrap().encrypt(&encryption, &chunk_data));
|
||||
chunk_data = try!(self.crypto.lock().unwrap().encrypt(encryption, &chunk_data));
|
||||
}
|
||||
let mut path = db.layout.temp_bundle_path();
|
||||
let mut file = BufWriter::new(try!(File::create(&path).context(&path as &Path)));
|
||||
|
@ -121,7 +121,7 @@ impl BundleWriter {
|
|||
};
|
||||
let mut info_data = try!(msgpack::encode(&info).context(&path as &Path));
|
||||
if let Some(ref encryption) = self.encryption {
|
||||
info_data = try!(self.crypto.lock().unwrap().encrypt(&encryption, &info_data));
|
||||
info_data = try!(self.crypto.lock().unwrap().encrypt(encryption, &info_data));
|
||||
}
|
||||
let header = BundleHeader {
|
||||
encryption: self.encryption,
|
||||
|
|
|
@ -62,10 +62,9 @@ impl ChunkerType {
|
|||
|
||||
pub fn avg_size(&self) -> usize {
|
||||
match *self {
|
||||
ChunkerType::Ae(size) => size,
|
||||
ChunkerType::Ae(size) | ChunkerType::Fixed(size) => size,
|
||||
ChunkerType::Rabin((size, _seed)) => size,
|
||||
ChunkerType::FastCdc((size, _seed)) => size,
|
||||
ChunkerType::Fixed(size) => size
|
||||
ChunkerType::FastCdc((size, _seed)) => size
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,10 +74,9 @@ impl ChunkerType {
|
|||
|
||||
pub fn seed(&self) -> u64 {
|
||||
match *self {
|
||||
ChunkerType::Ae(_size) => 0,
|
||||
ChunkerType::Ae(_size) | ChunkerType::Fixed(_size) => 0,
|
||||
ChunkerType::Rabin((_size, seed)) => seed as u64,
|
||||
ChunkerType::FastCdc((_size, seed)) => seed,
|
||||
ChunkerType::Fixed(_size) => 0,
|
||||
ChunkerType::FastCdc((_size, seed)) => seed
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -160,7 +160,7 @@ impl Repository {
|
|||
if inode.file_type == FileType::Directory {
|
||||
let path = path.join(inode.name);
|
||||
for chunks in inode.children.unwrap().values() {
|
||||
let inode = try!(self.get_inode(&chunks));
|
||||
let inode = try!(self.get_inode(chunks));
|
||||
queue.push_back((path.clone(), inode));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -201,7 +201,7 @@ impl Repository {
|
|||
|
||||
pub fn get_stream<W: Write>(&mut self, chunks: &[Chunk], w: &mut W) -> Result<(), RepositoryError> {
|
||||
for &(ref hash, len) in chunks {
|
||||
let data = try!(try!(self.get_chunk(*hash)).ok_or_else(|| IntegrityError::MissingChunk(hash.clone())));
|
||||
let data = try!(try!(self.get_chunk(*hash)).ok_or_else(|| IntegrityError::MissingChunk(*hash)));
|
||||
debug_assert_eq!(data.len() as u32, len);
|
||||
try!(w.write_all(&data));
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ impl Repository {
|
|||
},
|
||||
Some(FileData::ChunkedIndirect(ref chunks)) => {
|
||||
if try!(self.check_chunks(checked, chunks, true)) {
|
||||
let chunk_data = try!(self.get_data(&chunks));
|
||||
let chunk_data = try!(self.get_data(chunks));
|
||||
let chunks = ChunkList::read_from(&chunk_data);
|
||||
try!(self.check_chunks(checked, &chunks, true));
|
||||
}
|
||||
|
@ -191,12 +191,12 @@ impl Repository {
|
|||
try!(self.flush());
|
||||
backup.root = chunks;
|
||||
backup.modified = true;
|
||||
try!(self.evacuate_broken_backup(&name));
|
||||
try!(self.save_backup(&backup, &name));
|
||||
try!(self.evacuate_broken_backup(name));
|
||||
try!(self.save_backup(backup, name));
|
||||
},
|
||||
Err(err) => if repair {
|
||||
warn!("The root of the backup {} has been corrupted\n\tcaused by: {}", name, err);
|
||||
try!(self.evacuate_broken_backup(&name));
|
||||
try!(self.evacuate_broken_backup(name));
|
||||
} else {
|
||||
return Err(err)
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ impl Repository {
|
|||
};
|
||||
info!("Checking inode...");
|
||||
let mut checked = Bitmap::new(self.index.capacity());
|
||||
let mut inodes = try!(self.get_backup_path(&backup, path));
|
||||
let mut inodes = try!(self.get_backup_path(backup, path));
|
||||
let mut inode = inodes.pop().unwrap();
|
||||
let mut modified = false;
|
||||
if let Err(err) = self.check_inode_contents(&inode, &mut checked) {
|
||||
|
@ -260,8 +260,8 @@ impl Repository {
|
|||
try!(self.flush());
|
||||
backup.root = chunks;
|
||||
backup.modified = true;
|
||||
try!(self.evacuate_broken_backup(&name));
|
||||
try!(self.save_backup(&backup, &name));
|
||||
try!(self.evacuate_broken_backup(name));
|
||||
try!(self.save_backup(backup, name));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -249,7 +249,7 @@ impl Inode {
|
|||
|
||||
#[inline]
|
||||
pub fn decode(data: &[u8]) -> Result<Self, InodeError> {
|
||||
Ok(try!(msgpack::decode(&data)))
|
||||
Ok(try!(msgpack::decode(data)))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -299,7 +299,7 @@ impl Repository {
|
|||
if let Some(ref contents) = inode.data {
|
||||
match *contents {
|
||||
FileData::Inline(ref data) => {
|
||||
try!(file.write_all(&data));
|
||||
try!(file.write_all(data));
|
||||
},
|
||||
FileData::ChunkedDirect(ref chunks) => {
|
||||
try!(self.get_stream(chunks, &mut file));
|
||||
|
|
Loading…
Reference in New Issue