aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-11-17 21:57:38 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2020-11-17 21:57:38 +0100
commit6e4e535e0c1108bbd5a3f15e273e13868f4ece20 (patch)
treefd3530c0a6f2ff7c6e830fda1ad258e39f981c09
parentupdater: BOOLEAN is a char, whereas BOOL is an int (diff)
downloadwireguard-windows-6e4e535e0c1108bbd5a3f15e273e13868f4ece20.tar.xz
wireguard-windows-6e4e535e0c1108bbd5a3f15e273e13868f4ece20.zip
conf: delay removal of old configs until next reboot
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r--conf/migration_windows.go21
1 files changed, 15 insertions, 6 deletions
diff --git a/conf/migration_windows.go b/conf/migration_windows.go
index 848a1c34..ddcadf15 100644
--- a/conf/migration_windows.go
+++ b/conf/migration_windows.go
@@ -56,15 +56,24 @@ func maybeMigrateConfiguration(c string) {
continue
}
newFile.Close()
- os.Remove(oldPath)
+ oldPath16, err := windows.UTF16PtrFromString(oldPath)
+ if err == nil {
+ windows.MoveFileEx(oldPath16, nil, windows.MOVEFILE_DELAY_UNTIL_REBOOT)
+ }
migratedConfigs[strings.ToLower(oldPath)] = newPath
log.Printf("Migrated configuration from ā€˜%sā€™ to ā€˜%sā€™", oldPath, newPath)
}
- if os.Remove(oldC) == nil {
- oldLog := filepath.Join(oldRoot, "WireGuard", "log.bin")
- oldRoot := filepath.Join(oldRoot, "WireGuard")
- os.Remove(oldLog)
- os.Remove(oldRoot)
+ oldC16, err := windows.UTF16PtrFromString(oldC)
+ if err == nil {
+ windows.MoveFileEx(oldC16, nil, windows.MOVEFILE_DELAY_UNTIL_REBOOT)
+ }
+ oldLog16, err := windows.UTF16PtrFromString(filepath.Join(oldRoot, "WireGuard", "log.bin"))
+ if err == nil {
+ windows.MoveFileEx(oldLog16, nil, windows.MOVEFILE_DELAY_UNTIL_REBOOT)
+ }
+ oldRoot16, err := windows.UTF16PtrFromString(filepath.Join(oldRoot, "WireGuard"))
+ if err == nil {
+ windows.MoveFileEx(oldRoot16, nil, windows.MOVEFILE_DELAY_UNTIL_REBOOT)
}
if len(migratedConfigs) == 0 {
return