Perform tilde expansion in the config wrapper

This commit is contained in:
Audrius Butkevicius 2014-10-12 14:09:25 +01:00
parent 838670ccbc
commit a5fe4a3694
3 changed files with 7 additions and 7 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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
}
}