Support multiple content folders. Closes #2

This commit is contained in:
Stash Dev
2019-03-23 14:09:05 -07:00
parent d959d61e6c
commit ae9bbf237f
17 changed files with 1449 additions and 886 deletions

View File

@@ -54,13 +54,6 @@ func initConfig() {
viper.AddConfigPath("$HOME/.stash") // Look for the config in the home directory
viper.AddConfigPath(".") // Look for config in the working directory
viper.SetDefault(config.Database, paths.GetDefaultDatabaseFilePath())
// Set generated to the metadata path for backwards compat
if !viper.IsSet(config.Generated) {
viper.SetDefault(config.Generated, viper.GetString(config.Metadata))
}
err := viper.ReadInConfig() // Find and read the config file
if err != nil { // Handle errors reading the config file
_ = utils.Touch(paths.GetDefaultConfigFilePath())
@@ -69,6 +62,11 @@ func initConfig() {
}
}
viper.SetDefault(config.Database, paths.GetDefaultDatabaseFilePath())
// Set generated to the metadata path for backwards compat
viper.SetDefault(config.Generated, viper.GetString(config.Metadata))
// Watch for changes
viper.WatchConfig()
viper.OnConfigChange(func(e fsnotify.Event) {