From: Scott Worley Date: Wed, 18 Mar 2026 02:36:37 +0000 (-0700) Subject: Start on fsck: Invoke recover if data is missing X-Git-Url: http://git.scottworley.com/annex-ec/commitdiff_plain/f71977eb51487c263788a5bb797c1f09d3895084?ds=sidebyside Start on fsck: Invoke recover if data is missing --- diff --git a/annex-ec-fsck b/annex-ec-fsck new file mode 100755 index 0000000..2a6026c --- /dev/null +++ b/annex-ec-fsck @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + +# annex-ec: Use erasure codes for more efficient storage use in git-annex +# Copyright (C) 2026 Scott Worley + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +set -euo pipefail + +die() { + echo "$*" >&2 + exit 1 +} + +check_one_group() { + local where_data + where_data=$(set +e; git annex whereis --json "${recovery_set_files[@]}"; set -e) + missing_data=$(jq -r 'if .whereis == [] then .file else empty end' <<< "$where_data") + if [[ "$missing_data" ]];then + xargs -d \\n annex-ec-recover <<< "$missing_data" + fi +} + +check_all_groups() { + recovery_set_name= + recovery_set_files=() + while IFS= read -r line;do + if [[ "$line" == ' '* ]];then + recovery_set_files+=( "${line# }" ) + else + if [[ "$recovery_set_name" ]];then + check_one_group + fi + recovery_set_name=$line + recovery_set_files=() + fi + done < ec/.meta + check_one_group +} + +check_all_groups