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 22:15:53 +0100
commit2edb9007c820656514a0e9b07c9f83ad86593866 (patch)
tree86d80cdb6cdeeaaf1882eb66641865e3ad41d192
parentupdater: BOOLEAN is a char, whereas BOOL is an int (diff)
downloadwireguard-windows-2edb9007c820656514a0e9b07c9f83ad86593866.tar.xz
wireguard-windows-2edb9007c820656514a0e9b07c9f83ad86593866.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.go22
1 files changed, 15 insertions, 7 deletions
diff --git a/conf/migration_windows.go b/conf/migration_windows.go
index 848a1c34..c5915b11 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
@@ -112,5 +121,4 @@ func maybeMigrateConfiguration(c string) {
}
log.Printf("Migrated service command line arguments for ‘%s’", svcName)
}
-
}