From 3eb6c3150918fadef0066745e01245734766055f Mon Sep 17 00:00:00 2001 From: shuki Date: Fri, 6 Mar 2026 19:33:15 +0200 Subject: [PATCH] Show rsync verbose output in TUI and application log Replace tee with _snaplog_tee shell function that writes each line unbuffered to three destinations: snapshot log, application log file, and stderr (which the TUI captures for live display). This fixes the issue where rsync file-by-file output was invisible in both the Logs screen and the Running Tasks view due to pipe buffering. Co-Authored-By: Claude Opus 4.6 --- lib/rclone.sh | 2 +- lib/snaplog.sh | 10 ++++++++++ lib/transfer.sh | 4 ++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/rclone.sh b/lib/rclone.sh index 96375ff..9ab5838 100644 --- a/lib/rclone.sh +++ b/lib/rclone.sh @@ -98,7 +98,7 @@ _rclone_cmd() { local rc=0 if [[ -n "${_TRANSFER_LOG:-}" && "$subcmd" == "copy" ]]; then echo "=== rclone copy $* ===" >> "$_TRANSFER_LOG" - rclone "$subcmd" "${rclone_opts[@]}" --verbose "$@" > >(tee -a "$_TRANSFER_LOG") 2>&1 || rc=$? + rclone "$subcmd" "${rclone_opts[@]}" --verbose "$@" > >(_snaplog_tee) 2>&1 || rc=$? else rclone "$subcmd" "${rclone_opts[@]}" "$@" || rc=$? fi diff --git a/lib/snaplog.sh b/lib/snaplog.sh index 7cffc2d..cc5b5b6 100644 --- a/lib/snaplog.sh +++ b/lib/snaplog.sh @@ -4,6 +4,16 @@ [[ -n "${_GNIZA4LINUX_SNAPLOG_LOADED:-}" ]] && return 0 _GNIZA4LINUX_SNAPLOG_LOADED=1 +# Tee helper: writes each line to the transfer log, app log, and stderr (TUI). +# Used as process substitution target: cmd > >(_snaplog_tee) 2>&1 +_snaplog_tee() { + while IFS= read -r line; do + echo "$line" >> "${_TRANSFER_LOG}" + [[ -n "${LOG_FILE:-}" ]] && echo "$line" >> "${LOG_FILE}" + echo "$line" >&2 + done +} + # Initialize snapshot log directory and transfer log file. snaplog_init() { _SNAP_LOG_DIR=$(mktemp -d "${WORK_DIR}/gniza-snaplog-XXXXXX") diff --git a/lib/transfer.sh b/lib/transfer.sh index 9e964bf..50e3ec0 100644 --- a/lib/transfer.sh +++ b/lib/transfer.sh @@ -57,7 +57,7 @@ rsync_to_remote() { local rc=0 if [[ -n "${_TRANSFER_LOG:-}" ]]; then echo "=== rsync: $source_dir -> ${REMOTE_USER}@${REMOTE_HOST}:${remote_dest} ===" >> "$_TRANSFER_LOG" - "${rsync_cmd[@]}" > >(tee -a "$_TRANSFER_LOG") 2>&1 || rc=$? + "${rsync_cmd[@]}" > >(_snaplog_tee) 2>&1 || rc=$? else "${rsync_cmd[@]}" || rc=$? fi @@ -133,7 +133,7 @@ rsync_local() { local rc=0 if [[ -n "${_TRANSFER_LOG:-}" ]]; then echo "=== rsync (local): $source_dir -> $local_dest ===" >> "$_TRANSFER_LOG" - rsync "${rsync_opts[@]}" "$source_dir" "$local_dest" > >(tee -a "$_TRANSFER_LOG") 2>&1 || rc=$? + rsync "${rsync_opts[@]}" "$source_dir" "$local_dest" > >(_snaplog_tee) 2>&1 || rc=$? else rsync "${rsync_opts[@]}" "$source_dir" "$local_dest" || rc=$? fi