Skip to content
This repository has been archived by the owner on Jun 7, 2022. It is now read-only.

Commit

Permalink
Merge pull request #169 from darrenldl/dev
Browse files Browse the repository at this point in the history
Fixed check and sort mode progress tracking when handling blank blocks
  • Loading branch information
darrenldl committed Apr 12, 2019
2 parents 131558a + 91c04bf commit b9e3134
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 33 deletions.
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,26 @@

- Updated `calc` mode to use the same defaults as `encode` mode

- Bumped major version as this may break backwards compatibility
- Bumped major version as this may break backward compatibility

- Fixed `check` and `sort` mode progress tracking when dealing with blank blocks

- Previously blank blocks do not count toward progress made unless `--report-blank` is supplied

## 5.0.0

- Error-correcting versions of SeqBox are now called Error-correcting SeqBox or EC-SeqBox for short, and use the file extension `.ecsbx`
- This is done for easier differentiation between the extended versions and the original versions
- Fundamentally this does not change how blkar functions, as blkar does not take file extensions into account for all modes interacting with SBX containers
- Bumped major version as this may break backwards compatibility
- Bumped major version as this may break backward compatibility
- `Cargo.lock` update via `cargo update`

## 4.0.0

- Changed "Uid" to "UID" in encode help messages for consistency
- Changed default archiving options
- Changed from using SBX version 1 to using SBX version 17 with data parity ratio of 10:2 and burst error resistance level of 10 by default
- Bumped major version as this may break backwards compatibility
- Bumped major version as this may break backward compatibility
- Slight change in wording in calc mode error correction parameters interpretation
- Replaced the term "any" with "each" when referring to block set or super block set
- Updated sort mode to ignore failure to sort completely blank blocks by default
Expand Down
51 changes: 29 additions & 22 deletions src/check_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ pub struct Stats {
pub meta_or_par_blocks_decoded: u64,
pub data_or_par_blocks_decoded: u64,
pub blocks_decode_failed: u64,
pub okay_blank_blocks: u64,
total_blocks: u64,
start_time: f64,
end_time: f64,
Expand All @@ -90,9 +91,10 @@ impl Stats {
let total_blocks = calc_total_block_count(ref_block.get_version(), required_len);
Stats {
version: ref_block.get_version(),
blocks_decode_failed: 0,
meta_or_par_blocks_decoded: 0,
data_or_par_blocks_decoded: 0,
blocks_decode_failed: 0,
okay_blank_blocks: 0,
total_blocks,
start_time: 0.,
end_time: 0.,
Expand All @@ -113,7 +115,8 @@ impl ProgressReport for Stats {
fn units_so_far(&self) -> u64 {
(self.meta_or_par_blocks_decoded
+ self.data_or_par_blocks_decoded
+ self.blocks_decode_failed) as u64
+ self.blocks_decode_failed
+ self.okay_blank_blocks) as u64
}

fn total_units(&self) -> u64 {
Expand Down Expand Up @@ -252,29 +255,33 @@ pub fn check_file(param: &Param) -> Result<Option<Stats>, Error> {
Err(_) => {
// only report error if the buffer is not completely blank
// unless report blank is true
if param.report_blank
|| !misc_utils::buffer_is_blank(sbx_block::slice_buf(
ref_block.get_version(),
&buffer,
))
{
if json_printer.json_enabled() {
if param.verbose {
json_printer.print_open_bracket(None, BracketType::Curly);

print_maybe_json!(json_printer, "pos : {}", block_pos);

json_printer.print_close_bracket();
if misc_utils::buffer_is_blank(sbx_block::slice_buf(
ref_block.get_version(),
&buffer,
)) {
if param.report_blank {
if json_printer.json_enabled() {
if param.verbose {
json_printer.print_open_bracket(None, BracketType::Curly);

print_maybe_json!(json_printer, "pos : {}", block_pos);

json_printer.print_close_bracket();
}
} else {
print_if!(verbose => param, reporter =>
"Block failed check, version : {}, block size : {}, at byte {} (0x{:X})",
ver_usize,
block_size,
block_pos,
block_pos;);
}

stats.blocks_decode_failed += 1;
} else {
print_if!(verbose => param, reporter =>
"Block failed check, version : {}, block size : {}, at byte {} (0x{:X})",
ver_usize,
block_size,
block_pos,
block_pos;);
stats.okay_blank_blocks += 1;
}

} else {
stats.blocks_decode_failed += 1;
}
}
Expand Down
20 changes: 12 additions & 8 deletions src/sort_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ pub struct Stats {
pub data_blocks_decoded: u64,
pub parity_blocks_decoded: u64,
pub blocks_decode_failed: u64,
pub okay_blank_blocks: u64,
pub meta_blocks_same_order: u64,
pub meta_blocks_diff_order: u64,
pub data_blocks_same_order: u64,
Expand All @@ -118,10 +119,11 @@ impl Stats {
let total_blocks = calc_total_block_count(ref_block.get_version(), file_size);
Stats {
version: ref_block.get_version(),
blocks_decode_failed: 0,
meta_blocks_decoded: 0,
data_blocks_decoded: 0,
parity_blocks_decoded: 0,
blocks_decode_failed: 0,
okay_blank_blocks: 0,
total_blocks,
meta_blocks_same_order: 0,
meta_blocks_diff_order: 0,
Expand Down Expand Up @@ -149,7 +151,8 @@ impl ProgressReport for Stats {
(self.meta_blocks_decoded
+ self.data_blocks_decoded
+ self.parity_blocks_decoded
+ self.blocks_decode_failed) as u64
+ self.blocks_decode_failed
+ self.okay_blank_blocks) as u64
}

fn total_units(&self) -> u64 {
Expand Down Expand Up @@ -310,12 +313,13 @@ pub fn sort_file(param: &Param) -> Result<Option<Stats>, Error> {
if let Err(_) = block.sync_from_buffer(&buffer, Some(&pred)) {
// only consider it failed if the buffer is not completely blank
// unless report blank is true
if param.report_blank
|| !misc_utils::buffer_is_blank(sbx_block::slice_buf(
ref_block.get_version(),
&buffer,
))
{
if misc_utils::buffer_is_blank(sbx_block::slice_buf(ref_block.get_version(), &buffer)) {
if param.report_blank {
stats.blocks_decode_failed += 1;
} else {
stats.okay_blank_blocks += 1;
}
} else {
stats.blocks_decode_failed += 1;
}
continue;
Expand Down

0 comments on commit b9e3134

Please sign in to comment.