chore(syncthing): remove "default" folder concept (#10068)

This removes the creation of the `default` folder on startup. My feeling
is that the concept is not widely used or appreciated.
This commit is contained in:
Jakob Borg
2025-04-23 05:59:24 +00:00
committed by GitHub
parent 25e03ef9ab
commit 50480b89fc
3 changed files with 13 additions and 27 deletions
+6 -18
View File
@@ -65,7 +65,7 @@ func GenerateCertificate(certFile, keyFile string) (tls.Certificate, error) {
return tlsutil.NewCertificate(certFile, keyFile, tlsDefaultCommonName, deviceCertLifetimeDays)
}
func DefaultConfig(path string, myID protocol.DeviceID, evLogger events.Logger, noDefaultFolder, skipPortProbing bool) (config.Wrapper, error) {
func DefaultConfig(path string, myID protocol.DeviceID, evLogger events.Logger, skipPortProbing bool) (config.Wrapper, error) {
newCfg := config.New(myID)
if skipPortProbing {
@@ -76,30 +76,18 @@ func DefaultConfig(path string, myID protocol.DeviceID, evLogger events.Logger,
return nil, err
}
if noDefaultFolder {
l.Infoln("We will skip creation of a default folder on first start")
return config.Wrap(path, newCfg, myID, evLogger), nil
}
fcfg := newCfg.Defaults.Folder.Copy()
fcfg.ID = "default"
fcfg.Label = "Default Folder"
fcfg.FilesystemType = config.FilesystemTypeBasic
fcfg.Path = locations.Get(locations.DefFolder)
newCfg.Folders = append(newCfg.Folders, fcfg)
l.Infoln("Default folder created and/or linked to new config")
return config.Wrap(path, newCfg, myID, evLogger), nil
}
// LoadConfigAtStartup loads an existing config. If it doesn't yet exist, it
// creates a default one, without the default folder if noDefaultFolder is true.
// Otherwise it checks the version, and archives and upgrades the config if
// necessary or returns an error, if the version isn't compatible.
func LoadConfigAtStartup(path string, cert tls.Certificate, evLogger events.Logger, allowNewerConfig, noDefaultFolder, skipPortProbing bool) (config.Wrapper, error) {
// creates a default one. Otherwise it checks the version, and archives and
// upgrades the config if necessary or returns an error, if the version
// isn't compatible.
func LoadConfigAtStartup(path string, cert tls.Certificate, evLogger events.Logger, allowNewerConfig, skipPortProbing bool) (config.Wrapper, error) {
myID := protocol.NewDeviceID(cert.Certificate[0])
cfg, originalVersion, err := config.Load(path, myID, evLogger)
if fs.IsNotExist(err) {
cfg, err = DefaultConfig(path, myID, evLogger, noDefaultFolder, skipPortProbing)
cfg, err = DefaultConfig(path, myID, evLogger, skipPortProbing)
if err != nil {
return nil, fmt.Errorf("failed to generate default config: %w", err)
}