From 66de239481b97164087b4e27ff295ec97d93c079 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Wed, 18 Sep 2019 14:51:39 -0600 Subject: conf: do not create config folder and migrate if preset --- conf/migration_windows.go | 4 ++++ conf/path_windows.go | 2 ++ conf/store.go | 4 +++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/conf/migration_windows.go b/conf/migration_windows.go index d8d349f5..fb12eaf0 100644 --- a/conf/migration_windows.go +++ b/conf/migration_windows.go @@ -14,6 +14,10 @@ import ( ) func maybeMigrate(c string) { + if disableAutoMigration { + return + } + vol := filepath.VolumeName(c) withoutVol := strings.TrimPrefix(c, vol) oldRoot := filepath.Join(vol, "\\windows.old") diff --git a/conf/path_windows.go b/conf/path_windows.go index 2997114e..a53968c5 100644 --- a/conf/path_windows.go +++ b/conf/path_windows.go @@ -14,6 +14,7 @@ import ( var cachedConfigFileDir string var cachedRootDir string +var disableAutoMigration bool func tunnelConfigurationsDirectory() (string, error) { if cachedConfigFileDir != "" { @@ -38,6 +39,7 @@ func tunnelConfigurationsDirectory() (string, error) { // consumers of our libraries who might want to do strange things. func PresetRootDirectory(root string) { cachedRootDir = root + disableAutoMigration = true } func RootDirectory() (string, error) { diff --git a/conf/store.go b/conf/store.go index 504a0d01..21bd3a22 100644 --- a/conf/store.go +++ b/conf/store.go @@ -129,7 +129,9 @@ func LoadFromName(name string) (*Config, error) { } func LoadFromPath(path string) (*Config, error) { - tunnelConfigurationsDirectory() // Provoke migrations, if needed. + if !disableAutoMigration { + tunnelConfigurationsDirectory() // Provoke migrations, if needed. + } name, err := NameFromPath(path) if err != nil { -- cgit v1.2.3-59-g8ed1b