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

Safety reinforcement

This commit is contained in:
Tw93
2025-12-08 17:50:46 +08:00
parent 2cb800d1e4
commit 03385c98bc
3 changed files with 4 additions and 4 deletions

View File

@@ -138,7 +138,7 @@ clean_orphaned_app_data() {
# Merge all results
cat "$scan_tmp_dir"/*.txt >> "$installed_bundles" 2> /dev/null || true
rm -rf "$scan_tmp_dir"
safe_remove "$scan_tmp_dir" true
# Deduplicate
sort -u "$installed_bundles" -o "$installed_bundles"

View File

@@ -304,7 +304,7 @@ cleanup_temp_files() {
if [[ ${#MOLE_TEMP_DIRS[@]} -gt 0 ]]; then
for file in "${MOLE_TEMP_DIRS[@]}"; do
[[ -d "$file" ]] && rm -rf "$file" 2> /dev/null || true
[[ -d "$file" ]] && rm -rf "$file" 2> /dev/null || true # SAFE: cleanup_temp_files
done
fi

View File

@@ -100,7 +100,7 @@ safe_remove() {
debug_log "Removing: $path"
# Perform the deletion
if rm -rf "$path" 2> /dev/null; then
if rm -rf "$path" 2> /dev/null; then # SAFE: safe_remove implementation
return 0
else
[[ "$silent" != "true" ]] && log_error "Failed to remove: $path"
@@ -135,7 +135,7 @@ safe_sudo_remove() {
debug_log "Removing (sudo): $path"
# Perform the deletion
if sudo rm -rf "$path" 2> /dev/null; then
if sudo rm -rf "$path" 2> /dev/null; then # SAFE: safe_sudo_remove implementation
return 0
else
log_error "Failed to remove (sudo): $path"