1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-04 17:24:45 +00:00

Implemented safer temp cleanup and error reporting while fixing folded-directory size fallback to prevent double counting and aligning Homebrew cleanup traps with safe removal.

This commit is contained in:
Tw93
2026-01-12 15:45:31 +08:00
parent 5d5056fc9e
commit 93dee7b94d
4 changed files with 57 additions and 7 deletions

View File

@@ -539,9 +539,14 @@ register_temp_dir() {
mktemp_file() {
local prefix="${1:-mole}"
local temp
local error_msg
# Use TMPDIR if set, otherwise /tmp
# Add .XXXXXX suffix to work with both BSD and GNU mktemp
temp=$(mktemp "${TMPDIR:-/tmp}/${prefix}.XXXXXX") || return 1
if ! error_msg=$(mktemp "${TMPDIR:-/tmp}/${prefix}.XXXXXX" 2>&1); then
echo "Error: Failed to create temporary file: $error_msg" >&2
return 1
fi
temp="$error_msg"
register_temp_file "$temp"
echo "$temp"
}