(cfg config.Wrapper, originalVersion int)
| 118 | } |
| 119 | |
| 120 | func archiveAndSaveConfig(cfg config.Wrapper, originalVersion int) error { |
| 121 | // Copy the existing config to an archive copy |
| 122 | archivePath := cfg.ConfigPath() + fmt.Sprintf(".v%d", originalVersion) |
| 123 | slog.Info("Archiving a copy of old config file format", slogutil.FilePath(archivePath)) |
| 124 | if err := copyFile(cfg.ConfigPath(), archivePath); err != nil { |
| 125 | return err |
| 126 | } |
| 127 | |
| 128 | // Do a regular atomic config sve |
| 129 | return cfg.Save() |
| 130 | } |
| 131 | |
| 132 | func copyFile(src, dst string) error { |
| 133 | bs, err := os.ReadFile(src) |
no test coverage detected