Fix ClamAV progress display to only update on file change
Problem: Progress display updated every 0.2s showing same filename repeatedly: Scanning... ⠹ | Last file: pickledperil.com-Dec-2025.gz | Elapsed: 1m Scanning... ⠸ | Last file: pickledperil.com-Dec-2025.gz | Elapsed: 1m Scanning... ⠼ | Last file: pickledperil.com-Dec-2025.gz | Elapsed: 1m This created spam and made it hard to see actual progress. Solution: Track last displayed filename and only update when it changes: - Added last_filename variable - Only printf when filename != last_filename - Removed spinner animation (unnecessary with file tracking) - Changed format to simpler: "Scanning: [filename] | Elapsed: [time]" Now displays: Scanning: pickledperil.com-Dec-2025.gz | Elapsed: 1m Scanning: awstats122025.pickledperil.com.txt | Elapsed: 1m 5s Scanning: error.log | Elapsed: 1m 10s Each line shows a new file being scanned, no repetition.
This commit is contained in:
@@ -967,8 +967,7 @@ for scanner in "${AVAILABLE_SCANNERS[@]}"; do
|
|||||||
|
|
||||||
# Monitor activity by watching log file growth
|
# Monitor activity by watching log file growth
|
||||||
last_size=0
|
last_size=0
|
||||||
spin_chars='⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏'
|
last_filename=""
|
||||||
spin_index=0
|
|
||||||
stall_counter=0
|
stall_counter=0
|
||||||
|
|
||||||
while kill -0 $CLAM_PID 2>/dev/null; do
|
while kill -0 $CLAM_PID 2>/dev/null; do
|
||||||
@@ -980,14 +979,14 @@ for scanner in "${AVAILABLE_SCANNERS[@]}"; do
|
|||||||
current_file=$(tail -1 "$LOG_DIR/clamav.log" 2>/dev/null | grep -o '/[^:]*' | head -1)
|
current_file=$(tail -1 "$LOG_DIR/clamav.log" 2>/dev/null | grep -o '/[^:]*' | head -1)
|
||||||
if [ -n "$current_file" ]; then
|
if [ -n "$current_file" ]; then
|
||||||
filename=$(basename "$current_file" 2>/dev/null || echo "...")
|
filename=$(basename "$current_file" 2>/dev/null || echo "...")
|
||||||
|
|
||||||
|
# Only update display when filename changes
|
||||||
|
if [ "$filename" != "$last_filename" ]; then
|
||||||
elapsed=$(($(date +%s) - SCAN_START))
|
elapsed=$(($(date +%s) - SCAN_START))
|
||||||
spin_char="${spin_chars:$spin_index:1}"
|
printf "\r Scanning: %s | Elapsed: %s " \
|
||||||
printf "\r Scanning... %s | Last file: %s | Elapsed: %s " \
|
"${filename:0:50}" "$(format_time $elapsed)"
|
||||||
"$spin_char" "${filename:0:40}" "$(format_time $elapsed)"
|
last_filename="$filename"
|
||||||
else
|
fi
|
||||||
elapsed=$(($(date +%s) - SCAN_START))
|
|
||||||
spin_char="${spin_chars:$spin_index:1}"
|
|
||||||
printf "\r Scanning... %s | Elapsed: %s " "$spin_char" "$(format_time $elapsed)"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check for stalled scan (no log growth in 60 seconds)
|
# Check for stalled scan (no log growth in 60 seconds)
|
||||||
@@ -1002,7 +1001,6 @@ for scanner in "${AVAILABLE_SCANNERS[@]}"; do
|
|||||||
last_size=$current_size
|
last_size=$current_size
|
||||||
fi
|
fi
|
||||||
|
|
||||||
spin_index=$(( (spin_index + 1) % 10 ))
|
|
||||||
sleep 0.2
|
sleep 0.2
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user