(followup) bitcoin#21244: Move GetBackupsDir to ArgsManager

This commit is contained in:
Vijay 2024-04-11 07:50:10 +05:30 committed by pasta
parent 1f4e26baf9
commit 262fe0ada6
No known key found for this signature in database
GPG Key ID: 52527BEDABE87984
4 changed files with 13 additions and 7 deletions

View File

@ -643,7 +643,7 @@ void openConfigfile()
void showBackups()
{
fs::path backupsDir = GetBackupsDir();
fs::path backupsDir = gArgs.GetBackupsDirPath();
/* Open folder with default browser */
if (fs::exists(backupsDir))

View File

@ -455,6 +455,14 @@ const fs::path& ArgsManager::GetDataDirPath(bool net_specific) const
return path;
}
fs::path ArgsManager::GetBackupsDirPath()
{
if (!IsArgSet("-walletbackupsdir"))
return GetDataDirPath() / "backups";
return fs::absolute(GetArg("-walletbackupsdir", ""));
}
void ArgsManager::ClearPathCache()
{
LOCK(cs_args);
@ -804,10 +812,7 @@ const fs::path &GetDataDir(bool fNetSpecific)
fs::path GetBackupsDir()
{
if (!gArgs.IsArgSet("-walletbackupsdir"))
return GetDataDir() / "backups";
return fs::absolute(gArgs.GetArg("-walletbackupsdir", ""));
return gArgs.GetBackupsDirPath();
}
bool CheckDataDirOption()

View File

@ -98,7 +98,6 @@ void ReleaseDirectoryLocks();
bool TryCreateDirectories(const fs::path& p);
fs::path GetDefaultDataDir();
const fs::path &GetDataDir(bool fNetSpecific = true);
fs::path GetBackupsDir();
// Return true if -datadir option points to a valid directory or is not specified.
bool CheckDataDirOption();
fs::path GetConfigFile(const std::string& confPath);
@ -279,6 +278,8 @@ public:
*/
const fs::path& GetDataDirPath(bool net_specific = true) const;
fs::path GetBackupsDirPath();
/**
* Clear cached directory paths
*/

View File

@ -5017,7 +5017,7 @@ bool CWallet::AutoBackupWallet(const fs::path& wallet_path, bilingual_str& error
return false;
}
fs::path backupsDir = GetBackupsDir();
fs::path backupsDir = gArgs.GetBackupsDirPath();
backupsDir.make_preferred();
if (!fs::exists(backupsDir))