From 8f41d90ab1e16a09e3f222a73557cbcc256e3b0a Mon Sep 17 00:00:00 2001 From: filoozom Date: Mon, 3 Mar 2014 08:46:20 +0100 Subject: [PATCH] Delete cfgFile before renaming it on Windows --- main.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 172331470..4e4400e2a 100644 --- a/main.go +++ b/main.go @@ -328,6 +328,13 @@ func saveConfigLoop(cfgFile string) { continue } + if runtime.GOOS == "windows" { + err := os.Remove(cfgFile) + if err != nil && !os.IsNotExist(err) { + warnln(err) + } + } + err = os.Rename(cfgFile+".tmp", cfgFile) if err != nil { warnln(err) @@ -557,7 +564,7 @@ func expandTilde(p string) string { if runtime.GOOS == "windows" { return p } - + if strings.HasPrefix(p, "~/") { return strings.Replace(p, "~", getUnixHomeDir(), 1) }