mirror of
https://github.com/tw93/Mole.git
synced 2026-02-04 15:04:42 +00:00
fix: resolve spinner display and Ctrl+C handling issues
- fix(clean): stop spinner before safe_clean outputs results - fix(uninstall): handle Ctrl+C during application scanning
This commit is contained in:
@@ -59,6 +59,24 @@ scan_applications() {
|
|||||||
local temp_file
|
local temp_file
|
||||||
temp_file=$(create_temp_file)
|
temp_file=$(create_temp_file)
|
||||||
|
|
||||||
|
# Local spinner_pid for cleanup
|
||||||
|
local spinner_pid=""
|
||||||
|
|
||||||
|
# Trap to handle Ctrl+C during scan
|
||||||
|
local scan_interrupted=false
|
||||||
|
# shellcheck disable=SC2329 # Function invoked indirectly via trap
|
||||||
|
trap_scan_cleanup() {
|
||||||
|
scan_interrupted=true
|
||||||
|
if [[ -n "$spinner_pid" ]]; then
|
||||||
|
kill -TERM "$spinner_pid" 2> /dev/null || true
|
||||||
|
wait "$spinner_pid" 2> /dev/null || true
|
||||||
|
fi
|
||||||
|
printf "\r\033[K" >&2
|
||||||
|
rm -f "$temp_file" "${temp_file}.sorted" "${temp_file}.progress" 2> /dev/null || true
|
||||||
|
exit 130
|
||||||
|
}
|
||||||
|
trap trap_scan_cleanup INT
|
||||||
|
|
||||||
local current_epoch
|
local current_epoch
|
||||||
current_epoch=$(get_epoch_seconds)
|
current_epoch=$(get_epoch_seconds)
|
||||||
|
|
||||||
@@ -228,7 +246,6 @@ scan_applications() {
|
|||||||
local progress_file="${temp_file}.progress"
|
local progress_file="${temp_file}.progress"
|
||||||
echo "0" > "$progress_file"
|
echo "0" > "$progress_file"
|
||||||
|
|
||||||
local spinner_pid=""
|
|
||||||
(
|
(
|
||||||
# shellcheck disable=SC2329 # Function invoked indirectly via trap
|
# shellcheck disable=SC2329 # Function invoked indirectly via trap
|
||||||
cleanup_spinner() { exit 0; }
|
cleanup_spinner() { exit 0; }
|
||||||
|
|||||||
Reference in New Issue
Block a user