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 #158 from darrenldl/dev
Browse files Browse the repository at this point in the history
Updated sort mode to ignore failure to sort completely blank blocks by default
  • Loading branch information
darrenldl committed Apr 7, 2019
2 parents 0d66195 + 64a8a58 commit 68a491d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
- 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
- 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
- Added `--report-blank` flag to toggle this behaviour

## 3.0.0

Expand Down
5 changes: 5 additions & 0 deletions src/cli_sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ Ignored if --dry-run is supplied.",
"Burst error resistance level to use for the output container.
Defaults to guessing the level (guesses up to 1000) used by the
original container and uses the result.",
))
.arg(Arg::with_name("report_blank").long("report-blank").help(
"Failure to sort completely blank blocks are ignored by default.
Specify this if you want blkar to report said failures as well.",
))
.arg(verbose_arg().help("Show reference block info"))
.arg(json_arg())
Expand Down Expand Up @@ -85,6 +89,7 @@ pub fn sort<'a>(matches: &ArgMatches<'a>) -> i32 {
get_ref_block_choice!(matches),
ref_from_pos,
ref_to_pos,
matches.is_present("report_blank"),
guess_burst_from_pos,
multi_pass,
&json_printer,
Expand Down
14 changes: 13 additions & 1 deletion src/sort_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub struct Param {
ref_block_choice: RefBlockChoice,
ref_block_from_pos: Option<u64>,
ref_block_to_pos: Option<RangeEnd<u64>>,
report_blank: bool,
guess_burst_from_pos: Option<u64>,
multi_pass: Option<MultiPassType>,
json_printer: Arc<JSONPrinter>,
Expand All @@ -56,6 +57,7 @@ impl Param {
ref_block_choice: RefBlockChoice,
ref_block_from_pos: Option<u64>,
ref_block_to_pos: Option<RangeEnd<u64>>,
report_blank: bool,
guess_burst_from_pos: Option<u64>,
multi_pass: Option<MultiPassType>,
json_printer: &Arc<JSONPrinter>,
Expand All @@ -72,6 +74,7 @@ impl Param {
ref_block_choice,
ref_block_from_pos,
ref_block_to_pos,
report_blank,
guess_burst_from_pos,
multi_pass,
json_printer: Arc::clone(json_printer),
Expand Down Expand Up @@ -305,7 +308,16 @@ pub fn sort_file(param: &Param) -> Result<Option<Stats>, Error> {
break_if_eof_seen!(read_res);

if let Err(_) = block.sync_from_buffer(&buffer, Some(&pred)) {
stats.blocks_decode_failed += 1;
// 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,
))
{
stats.blocks_decode_failed += 1;
}
continue;
}

Expand Down

0 comments on commit 68a491d

Please sign in to comment.