1
0
mirror of https://github.com/tw93/Mole.git synced 2026-03-23 22:05:07 +00:00

fix: Use du -P for accurate size calculation and add timeouts to channel sends to prevent blocking.

This commit is contained in:
tw93
2026-01-30 15:06:30 +08:00
parent 2865a788e8
commit 89dcb0c3b5
6 changed files with 38 additions and 15 deletions

View File

@@ -267,7 +267,7 @@ safe_sudo_remove() {
if sudo test -e "$path" 2> /dev/null; then
local size_kb
size_kb=$(sudo du -sk "$path" 2> /dev/null | awk '{print $1}' || echo "0")
size_kb=$(sudo du -skP "$path" 2> /dev/null | awk '{print $1}' || echo "0")
if [[ "$size_kb" -gt 0 ]]; then
file_size=$(bytes_to_human "$((size_kb * 1024))")
fi
@@ -297,7 +297,7 @@ safe_sudo_remove() {
local size_human=""
if oplog_enabled; then
if sudo test -e "$path" 2> /dev/null; then
size_kb=$(sudo du -sk "$path" 2> /dev/null | awk '{print $1}' || echo "0")
size_kb=$(sudo du -skP "$path" 2> /dev/null | awk '{print $1}' || echo "0")
if [[ "$size_kb" =~ ^[0-9]+$ ]] && [[ "$size_kb" -gt 0 ]]; then
size_human=$(bytes_to_human "$((size_kb * 1024))" 2> /dev/null || echo "${size_kb}KB")
fi