mirror of
https://github.com/tw93/Mole.git
synced 2026-03-22 19:05:07 +00:00
perf(clean): speed up memory report size pre-scan
This commit is contained in:
@@ -178,12 +178,13 @@ clean_deep_system() {
|
|||||||
# Count and size old files before deletion
|
# Count and size old files before deletion
|
||||||
local file_count=0
|
local file_count=0
|
||||||
local total_size_kb=0
|
local total_size_kb=0
|
||||||
while IFS= read -r -d '' file; do
|
local total_bytes=0
|
||||||
((file_count++))
|
local stats_out
|
||||||
local file_size
|
stats_out=$(sudo find "$mem_reports_dir" -type f -mtime +30 -exec stat -f "%z" {} + 2> /dev/null | awk '{c++; s+=$1} END {print c+0, s+0}' || true)
|
||||||
file_size=$(sudo stat -f%z "$file" 2> /dev/null || echo "0")
|
if [[ -n "$stats_out" ]]; then
|
||||||
((total_size_kb += file_size / 1024))
|
read -r file_count total_bytes <<< "$stats_out"
|
||||||
done < <(sudo find "$mem_reports_dir" -type f -mtime +30 -print0 2> /dev/null || true)
|
total_size_kb=$((total_bytes / 1024))
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "$file_count" -gt 0 ]]; then
|
if [[ "$file_count" -gt 0 ]]; then
|
||||||
if [[ "${DRY_RUN:-}" != "true" ]]; then
|
if [[ "${DRY_RUN:-}" != "true" ]]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user