From edfda965e9902f6bfd7f26558d67eff0a1d71942 Mon Sep 17 00:00:00 2001 From: bbedward Date: Thu, 1 Jan 2026 14:04:58 -0500 Subject: [PATCH] core: prevent stale path file --- core/cmd/dms/commands_root.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/core/cmd/dms/commands_root.go b/core/cmd/dms/commands_root.go index b1a2a647..cb98ba3f 100644 --- a/core/cmd/dms/commands_root.go +++ b/core/cmd/dms/commands_root.go @@ -50,15 +50,18 @@ func findConfig(cmd *cobra.Command, args []string) error { configStateFile := filepath.Join(getRuntimeDir(), "danklinux.path") if data, readErr := os.ReadFile(configStateFile); readErr == nil { - statePath := strings.TrimSpace(string(data)) - shellPath := filepath.Join(statePath, "shell.qml") - - if info, statErr := os.Stat(shellPath); statErr == nil && !info.IsDir() { - log.Debug("Using config from active session state file: %s", statePath) - configPath = statePath - log.Debug("Using config from: %s", configPath) - return nil // <-- Guard statement + if len(getAllDMSPIDs()) == 0 { + os.Remove(configStateFile) } else { + statePath := strings.TrimSpace(string(data)) + shellPath := filepath.Join(statePath, "shell.qml") + + if info, statErr := os.Stat(shellPath); statErr == nil && !info.IsDir() { + log.Debug("Using config from active session state file: %s", statePath) + configPath = statePath + log.Debug("Using config from: %s", configPath) + return nil + } os.Remove(configStateFile) } }