From f71977eb51487c263788a5bb797c1f09d3895084 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Tue, 17 Mar 2026 19:36:37 -0700 Subject: [PATCH] Start on fsck: Invoke recover if data is missing --- annex-ec-fsck | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 annex-ec-fsck 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 -- 2.51.2