From: Scott Worley Date: Wed, 18 Mar 2026 09:20:04 +0000 (-0700) Subject: Use more blocks on huge files. X-Git-Url: http://git.scottworley.com/annex-ec/commitdiff_plain/b2d80193f6cb1a1e04e3b5b94132ef1695c45cc6?hp=f0a67ca1ce50570d580b1a5324fa9549c4679537 Use more blocks on huge files. Otherwise, during recovery, par2 sometimes fails to read huge blocks with 'Cannot allocate memory' errors. --- diff --git a/annex-ec b/annex-ec index d569fcc..4741759 100755 --- a/annex-ec +++ b/annex-ec @@ -49,15 +49,17 @@ make_name() { volumes=() redundancy=1 +max_block_size=$((128*1024*1024)) block_size_is_a_multiple_of=4 # par2 requires that this be at least 4 blocks_per_file=10 -while getopts b:m:r:v: opt;do +while getopts b:m:r:v:x: opt;do case $opt in b) blocks_per_file=$OPTARG;; m) block_size_is_a_multiple_of=$OPTARG;; r) redundancy=$OPTARG;; v) parse_volume_list "$OPTARG";; - *) echo 'usage: annex-ec [-v remote1,remote2,...] [-r N] file file...' >&2; exit 1;; + x) max_block_size=$OPTARG;; + *) echo 'usage: annex-ec [-v remote1,remote2,...] [-r N] [-b N] [-x N] [-m N] file file...' >&2; exit 1;; esac done shift $((OPTIND - 1)) @@ -74,7 +76,11 @@ N=$((${#volumes[@]} - redundancy)) git annex get -- "$@" max_size=$(find -L "$@" -printf '%s\n' | sort -nr | head -n1) -block_size=$(( ((max_size/(block_size_is_a_multiple_of*blocks_per_file))+1) * block_size_is_a_multiple_of)) +while true;do + block_size=$(( ((max_size/(block_size_is_a_multiple_of*blocks_per_file))+1) * block_size_is_a_multiple_of)) + if (( block_size < max_block_size ));then break;fi + blocks_per_file=$((blocks_per_file + 1)) +done make_name "$@"