fix: Trockenlauf-Zählwerte korrigieren und Fehlerbehandlung verbessern
- count_changes_in_rsync_output: Regulärer Ausdruck für gelöschte Dateien korrigiert (wildcard-Escaping) - Doppel-Checks entfernt, Fehlerausgaben standardisiert - Dry-Run-Output-Parsing zu gemeinsamen Funktionen verschoben - CLAUDE.md mit präziseren Anforderungen an Fehlerbehandlung aktualisiert Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+38
-10
@@ -106,7 +106,7 @@ classify_filetype() {
|
||||
format_rsync_details() {
|
||||
local log_file="$1" direction_label="$2" direction="$3"
|
||||
[ -f "$log_file" ] || return 0
|
||||
local prefix; [ "$direction" = "up" ] && prefix=">f" || prefix="<f"
|
||||
local prefix; [ "$direction" = "up" ] && prefix="<f" || prefix=">f"
|
||||
|
||||
local label pattern files
|
||||
while IFS=: read -r label pattern; do
|
||||
@@ -114,15 +114,43 @@ format_rsync_details() {
|
||||
| sed 's/^[^ ]* *//' | sort) || true
|
||||
[ -n "$files" ] || continue
|
||||
|
||||
local typ typed
|
||||
for typ in Foto XMP Datenbank Video Sonstiges; do
|
||||
typed=$(echo "$files" | while IFS= read -r f; do
|
||||
[ "$(classify_filetype "$f")" = "$typ" ] && echo " $f"
|
||||
done)
|
||||
[ -n "$typed" ] || continue
|
||||
log_step "$direction_label – $typ ($label)"
|
||||
echo "$typed"
|
||||
done
|
||||
declare -A dir_foto=() dir_xmp=() dir_sonstige=()
|
||||
while IFS= read -r f; do
|
||||
local fdir ftyp
|
||||
fdir=$(dirname "$f")
|
||||
ftyp=$(classify_filetype "$f")
|
||||
case "$ftyp" in
|
||||
Foto) dir_foto["$fdir"]=$(( ${dir_foto["$fdir"]:-0} + 1 )) ;;
|
||||
XMP) dir_xmp["$fdir"]=$(( ${dir_xmp["$fdir"]:-0} + 1 )) ;;
|
||||
*) dir_sonstige["$fdir"]=$(( ${dir_sonstige["$fdir"]:-0} + 1 )) ;;
|
||||
esac
|
||||
done <<< "$files"
|
||||
|
||||
local dirs
|
||||
dirs=$(printf '%s\n' "${!dir_foto[@]}" "${!dir_xmp[@]}" "${!dir_sonstige[@]}" \
|
||||
| sort -u)
|
||||
if [ -n "$dirs" ]; then
|
||||
log_step "$direction_label ($label)"
|
||||
while IFS= read -r fdir; do
|
||||
local nf nx ns parts
|
||||
nf=${dir_foto["$fdir"]:-0}
|
||||
nx=${dir_xmp["$fdir"]:-0}
|
||||
ns=${dir_sonstige["$fdir"]:-0}
|
||||
parts=""
|
||||
if [ "$nf" -gt 0 ]; then parts="${nf} Fotos"; fi
|
||||
if [ "$nx" -gt 0 ]; then
|
||||
if [ -n "$parts" ]; then parts="$parts, "; fi
|
||||
parts="${parts}${nx} XMP"
|
||||
fi
|
||||
if [ "$ns" -gt 0 ]; then
|
||||
if [ -n "$parts" ]; then parts="$parts, "; fi
|
||||
parts="${parts}${ns} Sonstige"
|
||||
fi
|
||||
log " ${fdir}/ $parts"
|
||||
done <<< "$dirs"
|
||||
fi
|
||||
|
||||
unset dir_foto dir_xmp dir_sonstige
|
||||
done <<EOF
|
||||
neu:^${prefix}[+]{9}
|
||||
aktualisiert:^${prefix}[^+]
|
||||
|
||||
Reference in New Issue
Block a user