From 3bd3158817feca319c047d1ec87becea9c34f642 Mon Sep 17 00:00:00 2001 From: Terranom674 Date: Tue, 18 Aug 2026 21:56:30 +0200 Subject: [PATCH] Improve WebDAV sync failure diagnostics --- runtime/sync-webdav.sh | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/runtime/sync-webdav.sh b/runtime/sync-webdav.sh index 32e80ce..7af98f0 100644 --- a/runtime/sync-webdav.sh +++ b/runtime/sync-webdav.sh @@ -58,6 +58,10 @@ for target in (status_file, public_file): PY } +compact_output() { + tail -n 12 | tr '\n' ' ' | sed 's/[[:space:]]\+/ /g; s/^[[:space:]]//; s/[[:space:]]$//' +} + failure() { local code="$1" command="$2" line="$3" trap - ERR @@ -89,13 +93,29 @@ python3 "$SCRIPT_DIR/lib/shadow_tree.py" \ --state "$SHADOW_MAP_FILE" if [[ "${PIWIGO_SYNC_ENABLED:-0}" == "1" ]]; then - php "$SCRIPT_DIR/lib/piwigo-sync.php" \ + trap - ERR + PIWIGO_OUTPUT="" + PIWIGO_EXIT=0 + if PIWIGO_OUTPUT="$(php "$SCRIPT_DIR/lib/piwigo-sync.php" \ --piwigo-root="$PIWIGO_ROOT" \ --connection-id="$CONNECTION_ID" \ - --base-url="http://127.0.0.1" + --base-url="http://127.0.0.1" 2>&1)"; then + PIWIGO_EXIT=0 + else + PIWIGO_EXIT=$? + fi + [[ -z "$PIWIGO_OUTPUT" ]] || printf '%s\n' "$PIWIGO_OUTPUT" + + if [[ "$PIWIGO_EXIT" -ne 0 ]]; then + DETAIL="Exit-Code: $PIWIGO_EXIT" + if [[ -n "$PIWIGO_OUTPUT" ]]; then + DETAIL+="; Ausgabe: $(printf '%s\n' "$PIWIGO_OUTPUT" | compact_output)" + fi + write_status error "Piwigo-Synchronisierung des WebDAV-Shadow-Trees fehlgeschlagen" "$DETAIL" + exit "$PIWIGO_EXIT" + fi + write_status ok "WebDAV-Shadow-Tree und Piwigo-Synchronisierung erfolgreich" else write_status ok "WebDAV-Shadow-Tree erfolgreich; Registrierung erfolgt im selben Minutenlauf über den bestehenden produktiven Piwigo-Sync" fi - -trap - ERR