mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
ensure existing config file is removed prior to writing
This commit is contained in:
parent
c0703db094
commit
2fdbb91f87
@ -90,6 +90,13 @@ func Write() (path string, err error) {
|
||||
}
|
||||
}
|
||||
|
||||
// remove prior to writing new file
|
||||
if err := os.Remove(path); err != nil {
|
||||
if !os.IsNotExist(err) {
|
||||
return path, err
|
||||
}
|
||||
}
|
||||
|
||||
file, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE, 0644)
|
||||
if err != nil {
|
||||
return path, fmt.Errorf("failed to open config for writing: %s", err)
|
||||
|
Loading…
Reference in New Issue
Block a user