12 this_volume_name
=$
(join -j1 <(git config get annex.uuid
) <(git cat-file
-p git-annex
:uuid.log
|sort) | cut
-d' ' -f2)
14 mapfile
-d , tmp
<<< "$1"
16 for x
in "${tmp[@]}";do
20 if [[ "$x" == "$this_volume_name" ]];then
31 EXAMPLE_SUFFIX
='.vol0000+9999.par2'
32 EXAMPLE_ANNEX_INTERNAL_PREFIX
='ingest-'
33 EXAMPLE_ANNEX_INTERNAL_SUFFIX
='-1-1173fd7'
34 num_separating_dashes
=$
((N
- 1))
35 overhead
=$
(( ${#EXAMPLE_SUFFIX} + ${#EXAMPLE_ANNEX_INTERNAL_PREFIX} + ${#EXAMPLE_ANNEX_INTERNAL_SUFFIX} + num_separating_dashes
))
36 available
=$
((FILENAME_MAX
- overhead
))
37 len
=$
((available
/ N
))
38 name
=$
(find "$@" -printf '%l\n' | sed -r 's/.*SHA256E-s[0-9]+--//;s/\..*//' | cut
-c-$len | tr \\n
-)
44 block_size_is_a_multiple_of
=4 # par2 requires that this be at least 4
46 while getopts b
:m
:r
:v
: opt
;do
48 b
) blocks_per_file
=$OPTARG;;
49 m
) block_size_is_a_multiple_of
=$OPTARG;;
50 r
) redundancy
=$OPTARG;;
51 v
) parse_volume_list
"$OPTARG";;
52 *) echo 'usage: annex-ec [-v remote1,remote2,...] [-r N] file file...' >&2; exit 1;;
57 if (( ${#volumes[@]} == 0 ));then
58 parse_volume_list
"here,$(git remote | tr \\n ,)"
61 N
=$
((${#volumes[@]} - redundancy
))
63 (( $# == N
)) || die
"Expected $N files in this group ($N + $redundancy = ${#volumes[@]}), but got $#"
68 max_size
=$
(find -L "$@" -printf '%s\n' | sort -nr | head -n1)
69 block_size
=$
(( ((max_size
/(block_size_is_a_multiple_of
*blocks_per_file
))+1) * block_size_is_a_multiple_of
))
75 # TODO: Make this robust against being interrupted here
76 echo '* annex.numcopies=1' >> ec
/.gitattributes
77 git add ec
/.gitattributes
80 par2 c
-n"$redundancy" -c"$((blocks_per_file * redundancy))" -s"$block_size" "$name.par2" "$@"
86 target_volume
="${volumes[i]}"
87 for volume
in "${volumes[@]}";do
88 if [[ "$volume" != here
]];then
89 if [[ "$volume" == "$target_volume" ]]; then
90 git annex copy
--to "$volume" "$f"
97 for f
in ec
/"$name.vol"*;do
98 target_volume
="${volumes[i]}"
100 if [[ "$target_volume" != here
]];then
101 git annex move
--to "$target_volume" "$f"
108 target_volume
="${volumes[i]}"
109 echo "${f// /[[:space:]]} annex.numcopies=1" >> .gitattributes
110 for volume
in "${volumes[@]}";do
111 if [[ "$volume" != "$target_volume" ]]; then
112 if [[ "$volume" == here
]];then
115 git annex drop
--from "$volume" "$f"
121 git add .gitattributes