Making clippy happy again

This commit is contained in:
Dennis Schwerdel 2017-04-19 22:43:08 +02:00
parent d3e74d6b7f
commit db7c6ef4fb
11 changed files with 29 additions and 31 deletions

6
Cargo.lock generated
View File

@ -23,7 +23,7 @@ dependencies = [
"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)",
"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.2 (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)",
"sodiumoxide 0.0.14 (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)", "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]] [[package]]
name = "serde_utils" name = "serde_utils"
version = "0.5.1" version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ 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)",
@ -530,7 +530,7 @@ dependencies = [
"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 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.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 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 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" "checksum squash-sys 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "db1f9dde91d819b7746e153bc32489fa19e6a106c3d7f2b92187a4efbdc88b40"

View File

@ -8,7 +8,7 @@ description = "Deduplicating backup tool"
serde = "0.9" serde = "0.9"
rmp-serde = "0.12" rmp-serde = "0.12"
serde_yaml = "0.6" serde_yaml = "0.6"
serde_utils = "0.5.1" serde_utils = "0.5.2"
squash-sys = "0.9" squash-sys = "0.9"
quick-error = "1.1" quick-error = "1.1"
blake2-rfc = "0.2" blake2-rfc = "0.2"

View File

@ -255,13 +255,13 @@ impl BundleDb {
let id = bundle.id(); let id = bundle.id();
let (folder, filename) = self.layout.local_bundle_path(&id, self.local_bundles.len()); let (folder, filename) = self.layout.local_bundle_path(&id, self.local_bundles.len());
try!(fs::create_dir_all(&folder).context(&folder as &Path)); 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); self.local_bundles.insert(id, bundle);
Ok(()) Ok(())
} }
pub fn add_bundle(&mut self, bundle: BundleWriter) -> Result<BundleInfo, BundleDbError> { 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 { if bundle.info.mode == BundleMode::Meta {
try!(self.copy_remote_bundle_to_cache(&bundle)) 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> { 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()) Ok(try!(bundle.get_chunk_list()).clone())
} }

View File

@ -101,7 +101,7 @@ impl BundleReader {
info_data.resize(header.info_size, 0); info_data.resize(header.info_size, 0);
try!(file.read_exact(&mut info_data).context(path)); try!(file.read_exact(&mut info_data).context(path));
if let Some(ref encryption) = header.encryption { 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)); let mut info: BundleInfo = try!(msgpack::decode(&info_data).context(path));
info.encryption = header.encryption; info.encryption = header.encryption;
@ -131,7 +131,7 @@ impl BundleReader {
chunk_data.resize(self.info.chunk_list_size, 0); chunk_data.resize(self.info.chunk_list_size, 0);
try!(file.read_exact(&mut chunk_data).context(&self.path as &Path)); try!(file.read_exact(&mut chunk_data).context(&self.path as &Path));
if let Some(ref encryption) = self.info.encryption { 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 chunks = ChunkList::read_from(&chunk_data);
let mut chunk_positions = Vec::with_capacity(chunks.len()); 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> { fn decode_contents(&self, mut data: Vec<u8>) -> Result<Vec<u8>, BundleReaderError> {
if let Some(ref encryption) = self.info.encryption { 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 { if let Some(ref compression) = self.info.compression {
let mut stream = try!(compression.decompress_stream().context(&self.path as &Path)); let mut stream = try!(compression.decompress_stream().context(&self.path as &Path));

View File

@ -76,7 +76,7 @@ impl BundleUploader {
self.waiting.fetch_sub(1, Ordering::SeqCst); self.waiting.fetch_sub(1, Ordering::SeqCst);
self.wait.0.notify_all(); self.wait.0.notify_all();
let folder = dst_path.parent().unwrap(); 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::copy(&src_path, &dst_path).context(&dst_path as &Path));
try!(fs::remove_file(&src_path).context(&src_path as &Path)); try!(fs::remove_file(&src_path).context(&src_path as &Path));
debug!("Uploaded {:?} to {:?}", src_path, dst_path); debug!("Uploaded {:?} to {:?}", src_path, dst_path);

View File

@ -94,14 +94,14 @@ impl BundleWriter {
try!(stream.finish(&mut self.data).map_err(BundleWriterError::Compression)) try!(stream.finish(&mut self.data).map_err(BundleWriterError::Compression))
} }
if let Some(ref encryption) = self.encryption { 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 encoded_size = self.data.len();
let mut chunk_data = Vec::with_capacity(self.chunks.encoded_size()); let mut chunk_data = Vec::with_capacity(self.chunks.encoded_size());
self.chunks.write_to(&mut chunk_data).unwrap(); self.chunks.write_to(&mut chunk_data).unwrap();
let id = BundleId(self.hash_method.hash(&chunk_data)); let id = BundleId(self.hash_method.hash(&chunk_data));
if let Some(ref encryption) = self.encryption { 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 path = db.layout.temp_bundle_path();
let mut file = BufWriter::new(try!(File::create(&path).context(&path as &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)); let mut info_data = try!(msgpack::encode(&info).context(&path as &Path));
if let Some(ref encryption) = self.encryption { 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 { let header = BundleHeader {
encryption: self.encryption, encryption: self.encryption,

View File

@ -62,10 +62,9 @@ impl ChunkerType {
pub fn avg_size(&self) -> usize { pub fn avg_size(&self) -> usize {
match *self { match *self {
ChunkerType::Ae(size) => size, ChunkerType::Ae(size) | ChunkerType::Fixed(size) => size,
ChunkerType::Rabin((size, _seed)) => size, ChunkerType::Rabin((size, _seed)) => size,
ChunkerType::FastCdc((size, _seed)) => size, ChunkerType::FastCdc((size, _seed)) => size
ChunkerType::Fixed(size) => size
} }
} }
@ -75,10 +74,9 @@ impl ChunkerType {
pub fn seed(&self) -> u64 { pub fn seed(&self) -> u64 {
match *self { match *self {
ChunkerType::Ae(_size) => 0, ChunkerType::Ae(_size) | ChunkerType::Fixed(_size) => 0,
ChunkerType::Rabin((_size, seed)) => seed as u64, ChunkerType::Rabin((_size, seed)) => seed as u64,
ChunkerType::FastCdc((_size, seed)) => seed, ChunkerType::FastCdc((_size, seed)) => seed
ChunkerType::Fixed(_size) => 0,
} }
} }
} }

View File

@ -160,7 +160,7 @@ impl Repository {
if inode.file_type == FileType::Directory { if inode.file_type == FileType::Directory {
let path = path.join(inode.name); let path = path.join(inode.name);
for chunks in inode.children.unwrap().values() { 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)); queue.push_back((path.clone(), inode));
} }
} }

View File

@ -201,7 +201,7 @@ impl Repository {
pub fn get_stream<W: Write>(&mut self, chunks: &[Chunk], w: &mut W) -> Result<(), RepositoryError> { pub fn get_stream<W: Write>(&mut self, chunks: &[Chunk], w: &mut W) -> Result<(), RepositoryError> {
for &(ref hash, len) in chunks { 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); debug_assert_eq!(data.len() as u32, len);
try!(w.write_all(&data)); try!(w.write_all(&data));
} }

View File

@ -97,7 +97,7 @@ impl Repository {
}, },
Some(FileData::ChunkedIndirect(ref chunks)) => { Some(FileData::ChunkedIndirect(ref chunks)) => {
if try!(self.check_chunks(checked, chunks, true)) { 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); let chunks = ChunkList::read_from(&chunk_data);
try!(self.check_chunks(checked, &chunks, true)); try!(self.check_chunks(checked, &chunks, true));
} }
@ -191,12 +191,12 @@ impl Repository {
try!(self.flush()); try!(self.flush());
backup.root = chunks; backup.root = chunks;
backup.modified = true; backup.modified = true;
try!(self.evacuate_broken_backup(&name)); try!(self.evacuate_broken_backup(name));
try!(self.save_backup(&backup, &name)); try!(self.save_backup(backup, name));
}, },
Err(err) => if repair { Err(err) => if repair {
warn!("The root of the backup {} has been corrupted\n\tcaused by: {}", name, err); 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 { } else {
return Err(err) return Err(err)
} }
@ -213,7 +213,7 @@ impl Repository {
}; };
info!("Checking inode..."); info!("Checking inode...");
let mut checked = Bitmap::new(self.index.capacity()); 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 inode = inodes.pop().unwrap();
let mut modified = false; let mut modified = false;
if let Err(err) = self.check_inode_contents(&inode, &mut checked) { if let Err(err) = self.check_inode_contents(&inode, &mut checked) {
@ -260,8 +260,8 @@ impl Repository {
try!(self.flush()); try!(self.flush());
backup.root = chunks; backup.root = chunks;
backup.modified = true; backup.modified = true;
try!(self.evacuate_broken_backup(&name)); try!(self.evacuate_broken_backup(name));
try!(self.save_backup(&backup, &name)); try!(self.save_backup(backup, name));
} }
Ok(()) Ok(())
} }

View File

@ -249,7 +249,7 @@ impl Inode {
#[inline] #[inline]
pub fn decode(data: &[u8]) -> Result<Self, InodeError> { 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 { if let Some(ref contents) = inode.data {
match *contents { match *contents {
FileData::Inline(ref data) => { FileData::Inline(ref data) => {
try!(file.write_all(&data)); try!(file.write_all(data));
}, },
FileData::ChunkedDirect(ref chunks) => { FileData::ChunkedDirect(ref chunks) => {
try!(self.get_stream(chunks, &mut file)); try!(self.get_stream(chunks, &mut file));