mirror of
https://github.com/Jguer/yay
synced 2024-09-06 16:43:03 +00:00
Merge pull request #1147 from msAlcantara/master
Add error handler on saveConfig
This commit is contained in:
commit
f9ffa72b03
11
config.go
11
config.go
|
@ -126,18 +126,19 @@ var hideMenus = false
|
|||
|
||||
// SaveConfig writes yay config to file.
|
||||
func (config *Configuration) saveConfig() error {
|
||||
marshalledinfo, _ := json.MarshalIndent(config, "", "\t")
|
||||
marshalledinfo, err := json.MarshalIndent(config, "", "\t")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
in, err := os.OpenFile(configFile, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer in.Close()
|
||||
_, err = in.Write(marshalledinfo)
|
||||
if err != nil {
|
||||
if _, err = in.Write(marshalledinfo); err != nil {
|
||||
return err
|
||||
}
|
||||
err = in.Sync()
|
||||
return err
|
||||
return in.Sync()
|
||||
}
|
||||
|
||||
func defaultSettings() *Configuration {
|
||||
|
|
Loading…
Reference in a new issue