-
Notifications
You must be signed in to change notification settings - Fork 20.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
eth, node: use APPDATA env to support cygwin/msys correctly #17786
Conversation
Sorry for not following up with this last two weeks. I support this change, but fear that people will complain because geth doesn't find their old datadir anymore. Could you add a check to see whether there is a datadir at the old location? We already have backwards-compatibility checks like that for files inside datadir here. While we're at it, there is an old issue about this: #2239. It says we shouldn't use |
we can use
|
now, we can see how about this? @@ -59,12 +62,28 @@ func DefaultDataDir() string {
if runtime.GOOS == "darwin" {
return filepath.Join(home, "Library", "Ethereum")
} else if runtime.GOOS == "windows" {
+ dataDir := filepath.Join(home, "AppData", "Roaming", "Ethereum")
+ if common.FileExist(filepath.Join(dataDir, "chaindata")) {
+ log.Warn(fmt.Sprintf("XXX"))
+ return dataDir
+ }
appdata := os.Getenv("APPDATA")
if appdata != "" {
- return filepath.Join(appdata, "Ethereum")
+ dataDir = filepath.Join(appdata, "Ethereum")
+ } else {
+ dataDir = filepath.Join(home, "AppData", "Roaming", "Ethereum")
+ }
+ if common.FileExist(filepath.Join(dataDir, "chaindata")) {
+ log.Warn(fmt.Sprintf("XXX"))
+ return dataDir
+ }
+ localappdata := os.Getenv("LOCALAPPDATA")
+ if localappdata != "" {
+ dataDir = filepath.Join(localappdata, "Ethereum")
} else {
- return filepath.Join(home, "AppData", "Roaming", "Ethereum")
+ dataDir = filepath.Join(home, "AppData", "Local", "Ethereum")
}
+ return dataDir
} else {
return filepath.Join(home, ".ethereum")
} it looks somewhat ugly, but happy for old users and less issue for newcomers. |
Changing this also involves Mist, which (at least historically) has sometimes interacted directly with the keystore folder (although I don't remember exactly under what circumstances, maybe during import). cc @evertonfraga what would happen if we move the keystore ? |
…#17786) This changes default location of the data directory to use the LOCALAPPDATA environment variable, resolving issues with remote home directories an improving compatibility with Cygwin. Fixes ethereum#2239 Fixes ethereum#2237 Fixes ethereum#16437
…#17786) This changes default location of the data directory to use the LOCALAPPDATA environment variable, resolving issues with remote home directories an improving compatibility with Cygwin. Fixes ethereum#2239 Fixes ethereum#2237 Fixes ethereum#16437
since windows XP
$APPDATA (%APPDATA%)
is used.Please see also
for normal windows native environment,
%HOME%(C:\Users\foobar) + \AppData\Roaming
is correctly interpreted as%APPDATA%
, but for cygwin/msys2 environment or powershell,%HOME%
is/home/foobar/
and%HOME%
+\AppData\Roaming
is not%APPDATA%
anymore.Simply using
%APPDATA%
fix this issue.