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 #168 from darrenldl/dev
Browse files Browse the repository at this point in the history
Updated calc mode to use the same defaults as encode mode, version bump
  • Loading branch information
darrenldl committed Apr 12, 2019
2 parents 2b439fd + e0bdb68 commit 131558a
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 54 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
# Changelog

## 6.0.0

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

- Bumped major version as this may break backwards compatibility

## 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
- `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
- 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
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "blkar"
version = "5.0.0"
version = "6.0.0"
authors = ["Darren Ldl <darrenldldev@gmail.com>"]
edition = "2018"
build = "build.rs"
Expand Down
38 changes: 12 additions & 26 deletions src/cli_calc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub fn calc<'a>(matches: &ArgMatches<'a>) -> i32 {

json_printer.print_open_bracket(None, BracketType::Curly);

let version = get_version!(matches, json_printer);
let (version, data_par_burst) = get_ver_and_data_par_burst_w_defaults!(matches, json_printer);

let meta_enabled = Some(get_meta_enabled!(matches));

Expand All @@ -44,20 +44,6 @@ pub fn calc<'a>(matches: &ArgMatches<'a>) -> i32 {
Err(_) => exit_with_msg!(usr json_printer => "Invalid file size"),
};

let data_par_burst = if ver_uses_rs(version) {
// deal with RS related options
let data_shards = get_data_shards!(matches, version, json_printer);
let parity_shards = get_parity_shards!(matches, version, json_printer);

check_data_parity_shards!(data_shards, parity_shards, json_printer);

let burst = get_burst_or_zero!(matches, json_printer);

Some((data_shards, parity_shards, burst))
} else {
None
};

let out_file_size = file_utils::from_orig_file_size::calc_container_size(
version,
meta_enabled,
Expand Down Expand Up @@ -147,20 +133,20 @@ pub fn calc<'a>(matches: &ArgMatches<'a>) -> i32 {
if burst == 0 {
print_block!(
" The container can tolerate {} SBX block corruptions", par;
" in each block set";
" in each block set.";
"";
" A block set consists of {} blocks ({} bytes)", (data + par), (data + par) * block_size;
" A block set consists of {} blocks ({} bytes).", (data + par), (data + par) * block_size;
"";
" In total, {} blocks({} bytes) may be corrupted in", par, par * block_size;
" each block set";
" each block set.";
);
} else {
if burst == 1 {
print_block!(
" Warning :";
"";
" Burst error resistance level of {} may not provide", burst;
" meaningful resistance";
" meaningful resistance.";
"";
);
}
Expand All @@ -169,23 +155,23 @@ pub fn calc<'a>(matches: &ArgMatches<'a>) -> i32 {
let super_block_set_size = (data + par) * burst;

print_block!(" The container can tolerate {} burst SBX block corruptions in", par;
" each super block set ({} interleaved block sets)", burst;
" each super block set ({} interleaved block sets).", burst;
"";
" A block set consists of {} blocks ({} bytes)", block_set_size, block_set_size * block_size;
" A block set consists of {} blocks ({} bytes).", block_set_size, block_set_size * block_size;
"";
" A super block set consists of {} blocks ({} bytes)", super_block_set_size, super_block_set_size * block_size;
" A super block set consists of {} blocks ({} bytes).", super_block_set_size, super_block_set_size * block_size;
"";
" Each burst error may be up to {} blocks ({} bytes) in size", burst, burst * block_size;
" Each burst error may be up to {} blocks ({} bytes) in size.", burst, burst * block_size;
"";
" In total, {} sets of {} consecutive blocks ({} bytes) may be", par, burst, burst * block_size;
" corrupted in each super block set";
" corrupted in each super block set.";
"";
" The sets of corrupted blocks may be connected as well, so the";
" largest single burst error that can be tolerated in each super";
" block set is {} blocks({} bytes) in size", par * burst, par * burst * block_size;
" block set is {} blocks({} bytes) in size.", par * burst, par * burst * block_size;
"";
" Note that the actual tolerance depends on the behaviour of";
" the file system";
" the file system.";
);
}

Expand Down
8 changes: 4 additions & 4 deletions src/cli_decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,18 @@ pub fn decode<'a>(matches: &ArgMatches<'a>) -> i32 {
"Warning :";
"";
" Since output is stdout, blkar can only output data chunks in the";
" anticipated encoding order";
" anticipated encoding order.";
"";
" For version with no RS enabled (version 1, 2, 3), this means blkar";
" reads in the sequential pattern with optional metadata block and";
" outputs the data chunks";
" outputs the data chunks.";
"";
" For version with RS enabled (version 17, 18, 19), this means blkar";
" first guesses the burst resistance level, then reads using the block";
" set interleaving pattern and outputs the data chunks";
" set interleaving pattern and outputs the data chunks.";
"";
" blkar also tries to strip the data padding at the end of the container";
" at a best effort basis, but does not provide any guarantees";
" at a best effort basis, but does not provide any guarantees.";
"";
" If the ordering matches the anticipated ordering, output of blkar to";
" stdout should match the one produced in output to file mode. If the";
Expand Down
17 changes: 0 additions & 17 deletions src/cli_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,23 +192,6 @@ macro_rules! get_in_file {
}};
}

macro_rules! get_version {
(
$matches:expr, $json_printer:expr
) => {{
use crate::sbx_specs::string_to_ver;
match $matches.value_of("sbx_version") {
None => Version::V1,
Some(x) => match string_to_ver(&x) {
Ok(v) => v,
Err(()) => {
exit_with_msg!(usr $json_printer => "Invalid SBX version");
}
}
}
}}
}

macro_rules! get_data_shards {
(
$matches:expr, $version:expr, $json_printer:expr
Expand Down
8 changes: 4 additions & 4 deletions src/cli_repair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub fn repair<'a>(matches: &ArgMatches<'a>) -> i32 {

if matches.is_present("dry_run") && !json_printer.json_enabled() {
print_block!(
"Note : This is a dry run only, the container is not modified";
"Note : This is a dry run only, the container is not modified.";
"";
);
}
Expand All @@ -61,13 +61,13 @@ pub fn repair<'a>(matches: &ArgMatches<'a>) -> i32 {
print_block!(
"Warning :";
"";
" Repair mode modifies the SBX container in-place";
" Repair mode modifies the SBX container in-place.";
"";
" This may cause further damage to the container and prohibit further";
" data recovery if incorrect automatic repairs are made";
" data recovery if incorrect automatic repairs are made.";
"";
" It is advisable to make a copy of the container and work on the copy";
" rather than repairing the original container directly";
" rather than repairing the original container directly.";
"";
);

Expand Down
2 changes: 1 addition & 1 deletion src/decode_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ pub fn decode(
"Warning :";
"";
" Reference block is not a metadata block, output file";
" may contain data padding";
" may contain data padding.";
"";)
}
}
Expand Down

0 comments on commit 131558a

Please sign in to comment.