From a5fe4a36942bed4df3b0cab2016637073bcb202e Mon Sep 17 00:00:00 2001 From: Audrius Butkevicius Date: Sun, 12 Oct 2014 14:09:25 +0100 Subject: [PATCH] Perform tilde expansion in the config wrapper --- cmd/syncthing/main.go | 6 ------ internal/config/config.go | 2 +- internal/config/wrapper.go | 6 ++++++ 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cmd/syncthing/main.go b/cmd/syncthing/main.go index fbc1c8c14..587b8c0e5 100644 --- a/cmd/syncthing/main.go +++ b/cmd/syncthing/main.go @@ -575,17 +575,11 @@ func setupGUI(cfg *config.ConfigWrapper, m *model.Model) { } func sanityCheckFolders(cfg *config.ConfigWrapper, m *model.Model) { - var err error - nextFolder: for id, folder := range cfg.Folders() { if folder.Invalid != "" { continue } - folder.Path, err = osutil.ExpandTilde(folder.Path) - if err != nil { - l.Fatalln("home:", err) - } m.AddFolder(folder) fi, err := os.Stat(folder.Path) diff --git a/internal/config/config.go b/internal/config/config.go index 8400106a8..8d90d9200 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -377,7 +377,7 @@ func convertV5V6(cfg *Configuration) { // Added ".stfolder" file at folder roots to identify mount issues // Doesn't affect the config itself, but uses config migrations to identify // the migration point. - for _, folder := range cfg.Folders { + for _, folder := range Wrap("", *cfg).Folders() { err := folder.CreateMarker() if err != nil { panic(err) diff --git a/internal/config/wrapper.go b/internal/config/wrapper.go index e83aac4e3..b5070789b 100644 --- a/internal/config/wrapper.go +++ b/internal/config/wrapper.go @@ -167,6 +167,12 @@ func (w *ConfigWrapper) Folders() map[string]FolderConfiguration { if w.folderMap == nil { w.folderMap = make(map[string]FolderConfiguration, len(w.cfg.Folders)) for _, fld := range w.cfg.Folders { + path, err := osutil.ExpandTilde(fld.Path) + if err != nil { + l.Warnln("home:", err) + continue + } + fld.Path = path w.folderMap[fld.ID] = fld } }