mirror of https://github.com/dswd/zvault
Bugfix
This commit is contained in:
parent
2f3c97a043
commit
98a09fea2e
|
@ -14,6 +14,7 @@ This project follows [semantic versioning](http://semver.org).
|
|||
* [fixed] Also including the first min_size bytes in hash
|
||||
* [fixed] Fixed some texts in manpages
|
||||
* [fixed] Calling strip on final binaries
|
||||
* [fixed] Fixed bug that caused repairs to miss some errors
|
||||
|
||||
|
||||
### v0.4.0 (2017-07-21)
|
||||
|
|
|
@ -214,7 +214,7 @@ fn validate_repo_path(
|
|||
|
||||
|
||||
fn parse_filesize(num: &str) -> Result<u64, String> {
|
||||
let (num, suffix) = if num.len() > 0 {
|
||||
let (num, suffix) = if !num.is_empty() {
|
||||
num.split_at(num.len() - 1)
|
||||
} else {
|
||||
(num, "b")
|
||||
|
|
|
@ -138,7 +138,7 @@ fn get_backup(repo: &Repository, backup_name: &str) -> Result<Backup, ErrorCode>
|
|||
fn get_inode(repo: &mut Repository, backup: &Backup, inode: Option<&String>) -> Result<Inode, ErrorCode> {
|
||||
Ok(if let Some(inode) = inode {
|
||||
checked!(
|
||||
repo.get_backup_inode(&backup, &inode),
|
||||
repo.get_backup_inode(backup, &inode),
|
||||
"load subpath inode",
|
||||
ErrorCode::LoadInode
|
||||
)
|
||||
|
@ -340,7 +340,7 @@ fn print_repostats(stats: &RepositoryStatistics) {
|
|||
let disp = &stats.index.displacement;
|
||||
tr_println!("Displacement:\n - average: {:.1}\n - stddev: {:.1}\n - over {:.1}: {:.0}, {:.1}%\n - maximum: {:.0}",
|
||||
disp.avg, disp.stddev, disp.avg + 2.0 * disp.stddev, disp.count_xl, disp.count_xl as f32 / disp.count as f32 * 100.0, disp.max);
|
||||
println!("");
|
||||
println!();
|
||||
tr_println!("Bundles\n=======");
|
||||
let tsize = (stats.bundles.raw_size.count as f32 * stats.bundles.encoded_size.avg) as u64;
|
||||
tr_println!("All bundles: {} in {} bundles", to_file_size(tsize), stats.bundles.raw_size.count);
|
||||
|
@ -366,7 +366,7 @@ fn print_repostats(stats: &RepositoryStatistics) {
|
|||
tr_println!(" - encoded size: ø = {}, maximum: {}", to_file_size(esize.avg as u64), to_file_size(esize.max as u64));
|
||||
let ccount = &stats.bundles.chunk_count_data;
|
||||
tr_println!(" - chunk count: ø = {:.1}, maximum: {:.0}", ccount.avg, ccount.max);
|
||||
println!("");
|
||||
println!();
|
||||
tr_println!("Bundle methods\n==============");
|
||||
tr_println!("Hash:");
|
||||
for (hash, &count) in &stats.bundles.hash_methods {
|
||||
|
@ -374,7 +374,7 @@ fn print_repostats(stats: &RepositoryStatistics) {
|
|||
}
|
||||
tr_println!("Compression:");
|
||||
for (compr, &count) in &stats.bundles.compressions {
|
||||
let compr_name = if let &Some(ref compr) = compr {
|
||||
let compr_name = if let Some(ref compr) = *compr {
|
||||
compr.to_string()
|
||||
} else {
|
||||
tr!("none").to_string()
|
||||
|
@ -383,7 +383,7 @@ fn print_repostats(stats: &RepositoryStatistics) {
|
|||
}
|
||||
tr_println!("Encryption:");
|
||||
for (encr, &count) in &stats.bundles.encryptions {
|
||||
let encr_name = if let &Some(ref encr) = encr {
|
||||
let encr_name = if let Some(ref encr) = *encr {
|
||||
to_hex(&encr.1[..])
|
||||
} else {
|
||||
tr!("none").to_string()
|
||||
|
|
16
src/index.rs
16
src/index.rs
|
@ -59,14 +59,14 @@ pub struct Header {
|
|||
}
|
||||
|
||||
|
||||
pub trait Key: Clone + Eq + Copy + Default {
|
||||
pub trait Key: Eq + Copy + Default {
|
||||
fn hash(&self) -> u64;
|
||||
fn is_used(&self) -> bool;
|
||||
fn clear(&mut self);
|
||||
}
|
||||
|
||||
|
||||
pub trait Value: Clone + Copy + Default {}
|
||||
pub trait Value: Copy + Default {}
|
||||
|
||||
|
||||
#[repr(packed)]
|
||||
|
@ -118,14 +118,6 @@ impl<K: Key, V> Entry<K, V> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<K: Clone + Key, V: Clone> Clone for Entry<K, V> {
|
||||
fn clone(&self) -> Self {
|
||||
Entry {
|
||||
key: *self.get_key(),
|
||||
data: self.get_data().clone()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum LocateResult {
|
||||
|
@ -416,12 +408,12 @@ impl<K: Key, V: Value> Index<K, V> {
|
|||
// we found a hole, stop shifting here
|
||||
break;
|
||||
}
|
||||
if entry.get_key().hash() as usize & self.mask == pos {
|
||||
if (entry.get_key().hash() as usize & self.mask) == pos {
|
||||
// we found an entry at the right position, stop shifting here
|
||||
break;
|
||||
}
|
||||
}
|
||||
self.data[last_pos] = self.data[pos].clone();
|
||||
self.data.swap(last_pos, pos);
|
||||
}
|
||||
self.data[last_pos].clear();
|
||||
}
|
||||
|
|
|
@ -549,7 +549,7 @@ impl Repository {
|
|||
}
|
||||
if let Some(ref children) = inode.children {
|
||||
for chunks in children.values() {
|
||||
let ch = try!(self.get_inode(&chunks));
|
||||
let ch = try!(self.get_inode(chunks));
|
||||
try!(self.count_sizes_recursive(&ch, sizes, min_size));
|
||||
}
|
||||
}
|
||||
|
@ -567,7 +567,7 @@ impl Repository {
|
|||
}
|
||||
if let Some(ref children) = inode.children {
|
||||
for chunks in children.values() {
|
||||
let ch = try!(self.get_inode(&chunks));
|
||||
let ch = try!(self.get_inode(chunks));
|
||||
try!(self.find_duplicates_recursive(&ch, &path, sizes, hashes));
|
||||
}
|
||||
}
|
||||
|
@ -580,7 +580,7 @@ impl Repository {
|
|||
let mut hashes = HashMap::new();
|
||||
if let Some(ref children) = inode.children {
|
||||
for chunks in children.values() {
|
||||
let ch = try!(self.get_inode(&chunks));
|
||||
let ch = try!(self.get_inode(chunks));
|
||||
try!(self.find_duplicates_recursive(&ch, Path::new(""), &sizes, &mut hashes));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,10 +108,11 @@ impl Repository {
|
|||
try!(self.check_chunks(checked, chunks, true));
|
||||
}
|
||||
Some(FileData::ChunkedIndirect(ref chunks)) => {
|
||||
if try!(self.check_chunks(checked, chunks, true)) {
|
||||
if try!(self.check_chunks(checked, chunks, false)) {
|
||||
let chunk_data = try!(self.get_data(chunks));
|
||||
let chunks = ChunkList::read_from(&chunk_data);
|
||||
try!(self.check_chunks(checked, &chunks, true));
|
||||
let chunks2 = ChunkList::read_from(&chunk_data);
|
||||
try!(self.check_chunks(checked, &chunks2, true));
|
||||
try!(self.check_chunks(checked, chunks, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ impl ValueStats {
|
|||
if stats.max < val {
|
||||
stats.max = val;
|
||||
}
|
||||
sum += val as f64;
|
||||
sum += f64::from(val);
|
||||
stats.count += 1;
|
||||
}
|
||||
stats.avg = (sum as f32) / (stats.count as f32);
|
||||
|
|
Loading…
Reference in New Issue