Files
flatrender/services/node-agent/internal/runner/aecrash.go
T

40 lines
1.2 KiB
Go
Raw Normal View History

package runner
import (
"os"
"os/exec"
"path/filepath"
)
// ClearAECrashState removes the markers After Effects uses to decide it crashed,
// so the blocking "Crash Repair Options" (Safe Mode) dialog never appears on a
// headless launch. Two parts:
//
// 1. SCRPriorState.json in each AE prefs version dir (session crash-recovery state).
// 2. HKCU\Software\Adobe\After Effects\AppStates — AE writes a per-session GUID
// subkey on startup and removes it on a clean exit; a leftover one (after a
// kill/crash) triggers Safe Mode. reg.exe is a Windows built-in (no external
// dep / cgo), so we shell out to it.
//
// Targeted (vs. wiping all prefs) so the node keeps its AE preferences. Safe no-op
// on non-Windows (APPDATA unset).
func ClearAECrashState() {
appData := os.Getenv("APPDATA")
if appData == "" {
return // non-Windows / dev
}
// 1. session crash-recovery files
base := filepath.Join(appData, "Adobe", "After Effects")
if entries, err := os.ReadDir(base); err == nil {
for _, e := range entries {
if e.IsDir() {
_ = os.Remove(filepath.Join(base, e.Name(), "SCRPriorState.json"))
}
}
}
// 2. registry session/crash state
_ = exec.Command("reg", "delete", `HKCU\Software\Adobe\After Effects\AppStates`, "/f").Run()
}