]> git.scottworley.com Git - annex-ec/blob - annex-ec-fsck
More tests
[annex-ec] / annex-ec-fsck
1 #!/usr/bin/env bash
2
3 # annex-ec: Use erasure codes for more efficient storage use in git-annex
4 # Copyright (C) 2026 Scott Worley
5
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU Affero General Public License as
8 # published by the Free Software Foundation, either version 3 of the
9 # License, or (at your option) any later version.
10
11 set -euo pipefail
12
13 die() {
14 echo "$*" >&2
15 exit 1
16 }
17
18 check_one_group() {
19 local where_data
20 where_data=$(set +e; git annex whereis --json "${recovery_set_files[@]}"; set -e)
21 missing_data=$(jq -r 'if .whereis == [] then .file else empty end' <<< "$where_data")
22 if [[ "$missing_data" ]];then
23 xargs -d \\n annex-ec-recover <<< "$missing_data"
24 fi
25 }
26
27 check_all_groups() {
28 recovery_set_name=
29 recovery_set_files=()
30 while IFS= read -r line;do
31 if [[ "$line" == ' '* ]];then
32 recovery_set_files+=( "${line# }" )
33 else
34 if [[ "$recovery_set_name" ]];then
35 check_one_group
36 fi
37 recovery_set_name=$line
38 recovery_set_files=()
39 fi
40 done < ec/.meta
41 check_one_group
42 }
43
44 check_all_groups