mirror of
https://github.com/tw93/Mole.git
synced 2026-02-15 16:55:06 +00:00
Merge branch 'main' of github.com:tw93/Mole
This commit is contained in:
@@ -71,7 +71,7 @@ scan_applications() {
|
|||||||
# This speeds up repeated scans significantly by caching app metadata
|
# This speeds up repeated scans significantly by caching app metadata
|
||||||
local cache_dir="$HOME/.cache/mole"
|
local cache_dir="$HOME/.cache/mole"
|
||||||
local cache_file="$cache_dir/app_scan_cache"
|
local cache_file="$cache_dir/app_scan_cache"
|
||||||
local cache_ttl=86400 # 24 hours
|
local cache_ttl=86400 # 24 hours
|
||||||
local force_rescan="${1:-false}"
|
local force_rescan="${1:-false}"
|
||||||
|
|
||||||
mkdir -p "$cache_dir" 2> /dev/null
|
mkdir -p "$cache_dir" 2> /dev/null
|
||||||
@@ -79,12 +79,12 @@ scan_applications() {
|
|||||||
# Check if cache exists and is fresh
|
# Check if cache exists and is fresh
|
||||||
if [[ $force_rescan == false && -f "$cache_file" ]]; then
|
if [[ $force_rescan == false && -f "$cache_file" ]]; then
|
||||||
local cache_age=$(($(date +%s) - $(get_file_mtime "$cache_file")))
|
local cache_age=$(($(date +%s) - $(get_file_mtime "$cache_file")))
|
||||||
[[ $cache_age -eq $(date +%s) ]] && cache_age=86401 # Handle mtime read failure
|
[[ $cache_age -eq $(date +%s) ]] && cache_age=86401 # Handle mtime read failure
|
||||||
if [[ $cache_age -lt $cache_ttl ]]; then
|
if [[ $cache_age -lt $cache_ttl ]]; then
|
||||||
# Cache hit - show brief feedback and return cached results
|
# Cache hit - show brief feedback and return cached results
|
||||||
if [[ -t 2 ]]; then
|
if [[ -t 2 ]]; then
|
||||||
echo -e "${GREEN}Loading from cache...${NC}" >&2
|
echo -e "${GREEN}Loading from cache...${NC}" >&2
|
||||||
sleep 0.3 # Brief pause so user sees the message
|
sleep 0.3 # Brief pause so user sees the message
|
||||||
fi
|
fi
|
||||||
echo "$cache_file"
|
echo "$cache_file"
|
||||||
return 0
|
return 0
|
||||||
@@ -95,7 +95,7 @@ scan_applications() {
|
|||||||
local inline_loading=false
|
local inline_loading=false
|
||||||
if [[ -t 1 && -t 2 ]]; then
|
if [[ -t 1 && -t 2 ]]; then
|
||||||
inline_loading=true
|
inline_loading=true
|
||||||
printf "\033[2J\033[H" >&2 # Clear screen for inline loading
|
printf "\033[2J\033[H" >&2 # Clear screen for inline loading
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local temp_file
|
local temp_file
|
||||||
@@ -156,9 +156,9 @@ scan_applications() {
|
|||||||
local max_parallel
|
local max_parallel
|
||||||
max_parallel=$(get_optimal_parallel_jobs "io")
|
max_parallel=$(get_optimal_parallel_jobs "io")
|
||||||
if [[ $max_parallel -lt 8 ]]; then
|
if [[ $max_parallel -lt 8 ]]; then
|
||||||
max_parallel=8 # At least 8 for good performance
|
max_parallel=8 # At least 8 for good performance
|
||||||
elif [[ $max_parallel -gt 32 ]]; then
|
elif [[ $max_parallel -gt 32 ]]; then
|
||||||
max_parallel=32 # Cap at 32 to avoid too many processes
|
max_parallel=32 # Cap at 32 to avoid too many processes
|
||||||
fi
|
fi
|
||||||
local pids=()
|
local pids=()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user