From 6e22e8a6fb4ca762a882cdb530359fb370d3177a Mon Sep 17 00:00:00 2001 From: Viktor Liu Date: Mon, 4 May 2026 19:14:03 +0200 Subject: [PATCH] Register temp file cleanup before close in ssh config writer --- client/ssh/config/manager.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/ssh/config/manager.go b/client/ssh/config/manager.go index 5854bc509..8d401c08c 100644 --- a/client/ssh/config/manager.go +++ b/client/ssh/config/manager.go @@ -234,14 +234,14 @@ func (m *Manager) writeSSHConfig(sshConfig string) error { return fmt.Errorf("create temp SSH config: %w", err) } tmpPath := tmp.Name() - if err := tmp.Close(); err != nil { - return fmt.Errorf("close temp SSH config %s: %w", tmpPath, err) - } defer func() { if err := os.Remove(tmpPath); err != nil && !os.IsNotExist(err) { log.Debugf("remove temp SSH config %s: %v", tmpPath, err) } }() + if err := tmp.Close(); err != nil { + return fmt.Errorf("close temp SSH config %s: %w", tmpPath, err) + } if err := writeFileWithTimeout(tmpPath, []byte(sshConfig), 0644); err != nil { return fmt.Errorf("write SSH config file %s: %w", tmpPath, err)