Skip to content

Commit 233a90d

Browse files
committed
fix: remove common
1 parent c1a02ef commit 233a90d

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

Diff for: config/config.go

+20-5
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,26 @@ func MigrateConfigV1() error {
193193
analyticsOptOut := GetConfig("common.analytics_opt_out")
194194
analyticsDeviceID := GetConfig("common.analytics_device_id")
195195

196-
// Clear the config
197-
viper.Set("version", 1)
198-
viper.Set("gas_station", map[string]interface{}{})
199-
viper.Set("analytics", map[string]interface{}{})
200-
viper.Set("common", nil)
196+
// Reset all viper settings
197+
viper.Reset()
198+
199+
// Reinitialize viper with the config file
200+
homeDir, err := os.UserHomeDir()
201+
if err != nil {
202+
return fmt.Errorf("failed to get user home directory: %v", err)
203+
}
204+
configPath := filepath.Join(homeDir, common.WeaveConfigFile)
205+
viper.SetConfigFile(configPath)
206+
207+
// Create new clean config structure
208+
newConfig := map[string]interface{}{
209+
"version": 1,
210+
"gas_station": map[string]interface{}{},
211+
"analytics": map[string]interface{}{},
212+
}
213+
214+
// Set the new base config
215+
viper.Set("", newConfig)
201216

202217
// Restore the data
203218
if gasStation != nil {

0 commit comments

Comments
 (0)