aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorAva Chow <github@achow101.com>2024-05-23 12:11:55 -0400
committerAva Chow <github@achow101.com>2024-05-23 12:11:55 -0400
commit915d7276e4060999bac2a42c533b6fb8bdbe5b3d (patch)
tree75c7cc8fe58947b7454b2ee269c12f9fa8757a9d /src/common
parent867f6af803dcc9f0f754bf5cc683c853bb09051b (diff)
parent84900ac34f6888b7a851d0a6a5885192155f865c (diff)
Merge bitcoin/bitcoin#27064: system: use %LOCALAPPDATA% as default datadir on windows
84900ac34f6888b7a851d0a6a5885192155f865c doc: add release-notes-27064.md (Matthew Zipkin) 855dd8d592c951a2b3239867ffbf66bb8677d470 system: use %LOCALAPPDATA% as default datadir on windows (Matthew Zipkin) Pull request description: Closes https://github.com/bitcoin/bitcoin/issues/2391 This PR changes the default datadir location on Windows from `C:\Users\Username\AppData\Roaming\Bitcoin` to `C:\Users\Username\AppData\Local\Bitcoin`. This change only applies to fresh installs. To preserve backwards compatibility, on startup we check for the existence of `C:\Users\Username\AppData\Roaming\Bitcoin\chainstate` and if it is there, we continue using the "Roaming" directory as the default datadir location. [Note that in Windows 11 this change may be moot:](https://learn.microsoft.com/en-us/uwp/api/windows.storage.applicationdata.roamingfolder?view=winrt-22621) > Roaming data and settings is no longer supported as of Windows 11. The recommended replacement is [Azure App Service](https://learn.microsoft.com/en-us/azure/app-service/). Azure App Service is widely supported, well documented, reliable, and supports cross-platform/cross-ecosystem scenarios such as iOS, Android and web. Settings stored here no longer roam (as of Windows 11), but the settings store is still available. ACKs for top commit: achow101: ACK 84900ac34f6888b7a851d0a6a5885192155f865c BenWestgate: crACK https://github.com/bitcoin/bitcoin/commit/84900ac34f6888b7a851d0a6a5885192155f865c hebasto: re-ACK 84900ac34f6888b7a851d0a6a5885192155f865c, only addressed feedback since my recent [review](https://github.com/bitcoin/bitcoin/pull/27064#pullrequestreview-2028718273). Tree-SHA512: 807c6e89571287e2c8f4934229aec91ef28e7d0a675234acf1b7d085c24c7b73a08b6e345fbfc9038e6239187b6b69c08490ddaa1c057de5ea975c4a000bba42
Diffstat (limited to 'src/common')
-rw-r--r--src/common/args.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/common/args.cpp b/src/common/args.cpp
index c90eb0c685..caff36fdb3 100644
--- a/src/common/args.cpp
+++ b/src/common/args.cpp
@@ -696,12 +696,19 @@ bool HasTestOption(const ArgsManager& args, const std::string& test_option)
fs::path GetDefaultDataDir()
{
- // Windows: C:\Users\Username\AppData\Roaming\Bitcoin
+ // Windows:
+ // old: C:\Users\Username\AppData\Roaming\Bitcoin
+ // new: C:\Users\Username\AppData\Local\Bitcoin
// macOS: ~/Library/Application Support/Bitcoin
// Unix-like: ~/.bitcoin
#ifdef WIN32
// Windows
- return GetSpecialFolderPath(CSIDL_APPDATA) / "Bitcoin";
+ // Check for existence of datadir in old location and keep it there
+ fs::path legacy_path = GetSpecialFolderPath(CSIDL_APPDATA) / "Bitcoin";
+ if (fs::exists(legacy_path)) return legacy_path;
+
+ // Otherwise, fresh installs can start in the new, "proper" location
+ return GetSpecialFolderPath(CSIDL_LOCAL_APPDATA) / "Bitcoin";
#else
fs::path pathRet;
char* pszHome = getenv("HOME");