Skip to content

Commit

Permalink
fix: only modify ssh config file when required (#1700)
Browse files Browse the repository at this point in the history
Signed-off-by: Toma Puljak <[email protected]>
  • Loading branch information
Tpuljak authored Jan 10, 2025
1 parent 237e138 commit f9ece40
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions cmd/daytona/config/ssh_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,15 @@ func ensureSshFilesLinked() error {
return err
}

newContent := strings.ReplaceAll(string(content), "Include daytona_config\n\n", "")
newContent = strings.ReplaceAll(string(newContent), "Include daytona_config\n", "")
newContent = strings.ReplaceAll(string(newContent), "Include daytona_config", "")
contentStr := string(content)

if strings.HasPrefix(contentStr, "Include daytona_config") {
return nil
}

newContent := strings.ReplaceAll(contentStr, "Include daytona_config\n\n", "")
newContent = strings.ReplaceAll(newContent, "Include daytona_config\n", "")
newContent = strings.ReplaceAll(newContent, "Include daytona_config", "")
newContent = "Include daytona_config\n\n" + newContent
err = os.WriteFile(configFile, []byte(newContent), 0600)
if err != nil {
Expand Down

0 comments on commit f9ece40

Please sign in to comment.