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

Merge pull request #294 from JackPhallen/fix/remove-tm-mount-check

fix: remove Time Machine mount check
This commit is contained in:
Tw93
2026-01-12 11:56:33 +08:00
committed by GitHub
2 changed files with 3 additions and 25 deletions

View File

@@ -267,40 +267,21 @@ tm_is_running() {
grep -qE '(^|[[:space:]])("Running"|Running)[[:space:]]*=[[:space:]]*1([[:space:]]*;|$)' <<< "$st"
}
# Returns 0 if snapshot mounts exist under local snapshot paths
# Returns 1 if none found
# Returns 2 if mount state cannot be determined
tm_snapshots_mounted() {
local m
if ! m="$(run_with_timeout 3 mount 2> /dev/null)"; then
return 2
fi
# Match modern and legacy local-snapshot browse mounts:
# - /Volumes/com.apple.TimeMachine.localsnapshots/... (APFS)
# - /.TimeMachine (APFS)
# - /Volumes/MobileBackups (HFS+, legacy)
grep -qE '[[:space:]]on[[:space:]](/\.TimeMachine(/|[[:space:]])|/Volumes/com\.apple\.TimeMachine\.localsnapshots(/|[[:space:]])|/Volumes/MobileBackups(/|[[:space:]]))' <<< "$m"
}
# Local APFS snapshots (keep the most recent).
clean_local_snapshots() {
if ! command -v tmutil > /dev/null 2>&1; then
return 0
fi
local rc_running rc_mounted
rc_running=0
local rc_running=0
tm_is_running || rc_running=$?
rc_mounted=0
tm_snapshots_mounted || rc_mounted=$?
if [[ $rc_running -eq 2 || $rc_mounted -eq 2 ]]; then
if [[ $rc_running -eq 2 ]]; then
echo -e " ${YELLOW}!${NC} Could not determine Time Machine status; skipping snapshot cleanup"
return 0
fi
if [[ $rc_running -eq 0 || $rc_mounted -eq 0 ]]; then
if [[ $rc_running -eq 0 ]]; then
echo -e " ${YELLOW}!${NC} Time Machine is active; skipping snapshot cleanup"
return 0
fi

View File

@@ -126,7 +126,6 @@ tmutil() {
start_section_spinner(){ :; }
stop_section_spinner(){ :; }
tm_is_running(){ return 1; }
tm_snapshots_mounted(){ return 1; }
DRY_RUN="false"
clean_local_snapshots
@@ -157,7 +156,6 @@ start_section_spinner(){ :; }
stop_section_spinner(){ :; }
note_activity(){ :; }
tm_is_running(){ return 1; }
tm_snapshots_mounted(){ return 1; }
DRY_RUN="true"
clean_local_snapshots
@@ -193,7 +191,6 @@ start_section_spinner(){ :; }
stop_section_spinner(){ :; }
note_activity(){ :; }
tm_is_running(){ return 1; }
tm_snapshots_mounted(){ return 1; }
unset -f read_key