on main help sign in
refactor: improve check a little bit
ca6a55aAndrey Nering
internal/config/load.go+3−5
@@ -310,17 +310,15 @@ func (c *Config) setDefaults(workingDir, dataDir string) {
310 if c.Options.ContextPaths == nil {
310 if c.Options.ContextPaths == nil {
311 c.Options.ContextPaths = []string{}
311 c.Options.ContextPaths = []string{}
312 }
312 }
313+ if dataDir != "" {
314+ c.Options.DataDirectory = dataDir
313− if c.Options.DataDirectory == "" {
315+ } else if c.Options.DataDirectory == "" {
314 if path, ok := fsext.SearchParent(workingDir, defaultDataDirectory); ok {
316 if path, ok := fsext.SearchParent(workingDir, defaultDataDirectory); ok {
315 c.Options.DataDirectory = path
317 c.Options.DataDirectory = path
316 } else {
318 } else {
317 c.Options.DataDirectory = filepath.Join(workingDir, defaultDataDirectory)
319 c.Options.DataDirectory = filepath.Join(workingDir, defaultDataDirectory)
318 }
320 }
319 }
321 }
320− // explicit dataDir flag always takes precedence
321− if dataDir != "" {
322− c.Options.DataDirectory = dataDir
323− }
324 if c.Providers == nil {
322 if c.Providers == nil {
325 c.Providers = csync.NewMap[string, ProviderConfig]()
323 c.Providers = csync.NewMap[string, ProviderConfig]()
326 }
324 }