MCPcopy
hub / github.com/syncthing/syncthing / archiveAndSaveConfig

Function archiveAndSaveConfig

lib/syncthing/utils.go:120–130  ·  view source on GitHub ↗
(cfg config.Wrapper, originalVersion int)

Source from the content-addressed store, hash-verified

118}
119
120func 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
132func copyFile(src, dst string) error {
133 bs, err := os.ReadFile(src)

Callers 1

LoadConfigAtStartupFunction · 0.85

Calls 4

FilePathFunction · 0.92
copyFileFunction · 0.70
ConfigPathMethod · 0.65
SaveMethod · 0.65

Tested by

no test coverage detected