pocketnetteam / pocketnet.core

Decentralized social network based on the blockchain
https://pocketnet.app
Apache License 2.0
115 stars 28 forks source link

In the Documentation wrong Windows Extraction Directory #567

Closed graebeerd closed 10 months ago

graebeerd commented 1 year ago

In the documentation for extracting a snapshot to its directory you show:

# or for windows
$ cd %APPDATA%\Pocketcoin\

and it should be

# or for windows
$ cd %APPDATA%\Roaming\Pocketcoin\

wrong directory

lostystyg commented 1 year ago

I can prove this, last 0.21.2 version on Windows 11 uses %APPDATA%\Roaming\Pocketcoin\ directory as default. \ image \ @graebeerd thanks for catching this!

lostystyg commented 1 year ago

Btw, %APPDATA% is literally pointing to C:\Users\USERNAME\AppData\Roaming\. (https://superuser.com/questions/632891/what-is-appdata). So the documentation is technically correct, sorry for messing up

the-real-vortex-v commented 1 year ago

(Tested with V21.2 of the windows node) Under windows 10 (and as far as I know earlier versions). The registry key that holds the default data directory is:

HKEY_CURRENT_USER\SOFTWARE\Pocketcoin\Pocketcoin-Qt\strDataDir

open powershell and run this: get-itempropertyvalue -Path 'HKCU:\SOFTWARE\Pocketcoin\Pocketcoin-Qt\' -Name strDataDir

Or open CMD.exe and run this: reg query HKEY_CURRENT_USER\SOFTWARE\Pocketcoin\Pocketcoin-Qt\ /v strDataDir

The powershell method is better as it can put the result into a variable easily.

Either will spit out the current default directory.

Here is a two line power shell script to print it in windows:

$pdata=get-itempropertyvalue -Path 'HKCU:\SOFTWARE\Pocketcoin\Pocketcoin-Qt\' -Name strDataDir echo "The default Pocketnet Data Directory is: $pdata"

Here is a single line CMD.exe or powershell command using the reg.exe on windows 10 to set a new directory:

reg add "HKEY_CURRENT_USER\SOFTWARE\Pocketcoin\Pocketcoin-Qt\" /v strDataDir /t REG_SZ /d "d:\crypto\Pocketnet\Data"

The above command sets the strDataDir to point to "d:\crypto\pocketnet\data". Change that to whatever you want.


So if you want you could make a script to do your stuff fairly easy in powershell or just type in the commands manually. Example powershell:

$pdata=get-itempropertyvalue -Path 'HKCU:\SOFTWARE\Pocketcoin\Pocketcoin-Qt\' -Name strDataDir cd $pdata


FYI to find out the system defaults of the data dir etc I had to check src/util/system.cpp:

fs::path GetDefaultDataDir() { // Windows: C:\Users\Username\AppData\Roaming\Pocketcoin // macOS: ~/Library/Application Support/Pocketcoin // Unix-like: ~/.pocketcoin

ifdef WIN32

// Windows
return GetSpecialFolderPath(CSIDL_APPDATA) / "Pocketcoin";

else

fs::path pathRet;
char* pszHome = getenv("HOME");
if (pszHome == nullptr || strlen(pszHome) == 0)
    pathRet = fs::path("/");
else
    pathRet = fs::path(pszHome);

ifdef MAC_OSX

// macOS
return pathRet / "Library/Application Support/Pocketcoin";

else

// Unix-like
return pathRet / ".pocketcoin";

endif

endif

}