feat: backup the original file before manage it by lazyssh (#49)

This commit is contained in:
Adem Baccara
2025-09-12 19:32:09 +01:00
committed by GitHub
parent b7fb586e73
commit e75b61e819
4 changed files with 44 additions and 4 deletions
@@ -66,6 +66,11 @@ func (r *Repository) saveConfig(cfg *ssh_config.Config) error {
return fmt.Errorf("failed to write config to temporary file: %w", err)
}
// Ensure a one-time original backup exists before any modifications managed by lazyssh.
if err := r.createOriginalBackupIfNeeded(); err != nil {
return fmt.Errorf("failed to create original backup: %w", err)
}
if err := r.createBackup(); err != nil {
return fmt.Errorf("failed to create backup: %w", err)
}