Backport #15861 * Only write config in environment-to-ini if there are changes Only write the new config in environment-to-ini if there are changes or the destination is not the same as the customconf. Fix #15719 Fix #15857 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
parent
a3e8450fd5
commit
fa96ddb327
1 changed files with 11 additions and 3 deletions
|
@ -110,6 +110,8 @@ func runEnvironmentToIni(c *cli.Context) error {
|
||||||
}
|
}
|
||||||
cfg.NameMapper = ini.SnackCase
|
cfg.NameMapper = ini.SnackCase
|
||||||
|
|
||||||
|
changed := false
|
||||||
|
|
||||||
prefix := c.String("prefix") + "__"
|
prefix := c.String("prefix") + "__"
|
||||||
|
|
||||||
for _, kv := range os.Environ() {
|
for _, kv := range os.Environ() {
|
||||||
|
@ -143,16 +145,22 @@ func runEnvironmentToIni(c *cli.Context) error {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
oldValue := key.Value()
|
||||||
|
if !changed && oldValue != value {
|
||||||
|
changed = true
|
||||||
|
}
|
||||||
key.SetValue(value)
|
key.SetValue(value)
|
||||||
}
|
}
|
||||||
destination := c.String("out")
|
destination := c.String("out")
|
||||||
if len(destination) == 0 {
|
if len(destination) == 0 {
|
||||||
destination = setting.CustomConf
|
destination = setting.CustomConf
|
||||||
}
|
}
|
||||||
|
if destination != setting.CustomConf || changed {
|
||||||
err = cfg.SaveTo(destination)
|
err = cfg.SaveTo(destination)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if c.Bool("clear") {
|
if c.Bool("clear") {
|
||||||
for _, kv := range os.Environ() {
|
for _, kv := range os.Environ() {
|
||||||
idx := strings.IndexByte(kv, '=')
|
idx := strings.IndexByte(kv, '=')
|
||||||
|
|
Reference in a new issue