partial Merge #29040: refactor: Remove pre-C++20 code, fs::path cleanup

It fixes return reference to const variable under mutex which is not a good idea
This commit is contained in:
Konstantin Akimov 2024-09-26 00:47:28 +07:00
parent 042e8a4101
commit a219a8be15
No known key found for this signature in database
GPG Key ID: 2176C4A5D01EA524
2 changed files with 6 additions and 6 deletions

View File

@ -420,7 +420,7 @@ std::optional<unsigned int> ArgsManager::GetArgFlags(const std::string& name) co
return std::nullopt; return std::nullopt;
} }
const fs::path& ArgsManager::GetBlocksDirPath() const const fs::path ArgsManager::GetBlocksDirPath() const
{ {
LOCK(cs_args); LOCK(cs_args);
fs::path& path = m_cached_blocks_path; fs::path& path = m_cached_blocks_path;
@ -445,7 +445,7 @@ const fs::path& ArgsManager::GetBlocksDirPath() const
return path; return path;
} }
const fs::path& ArgsManager::GetDataDir(bool net_specific) const const fs::path ArgsManager::GetDataDir(bool net_specific) const
{ {
LOCK(cs_args); LOCK(cs_args);
fs::path& path = net_specific ? m_cached_network_datadir_path : m_cached_datadir_path; fs::path& path = net_specific ? m_cached_network_datadir_path : m_cached_datadir_path;

View File

@ -288,7 +288,7 @@ protected:
* *
* @return Blocks path which is network specific * @return Blocks path which is network specific
*/ */
const fs::path& GetBlocksDirPath() const; const fs::path GetBlocksDirPath() const;
/** /**
* Get data directory path * Get data directory path
@ -296,7 +296,7 @@ protected:
* @return Absolute path on success, otherwise an empty path when a non-directory path would be returned * @return Absolute path on success, otherwise an empty path when a non-directory path would be returned
* @post Returned directory path is created unless it is empty * @post Returned directory path is created unless it is empty
*/ */
const fs::path& GetDataDirBase() const { return GetDataDir(false); } const fs::path GetDataDirBase() const { return GetDataDir(false); }
/** /**
* Get data directory path with appended network identifier * Get data directory path with appended network identifier
@ -304,7 +304,7 @@ protected:
* @return Absolute path on success, otherwise an empty path when a non-directory path would be returned * @return Absolute path on success, otherwise an empty path when a non-directory path would be returned
* @post Returned directory path is created unless it is empty * @post Returned directory path is created unless it is empty
*/ */
const fs::path& GetDataDirNet() const { return GetDataDir(true); } const fs::path GetDataDirNet() const { return GetDataDir(true); }
fs::path GetBackupsDirPath(); fs::path GetBackupsDirPath();
@ -483,7 +483,7 @@ private:
* @return Absolute path on success, otherwise an empty path when a non-directory path would be returned * @return Absolute path on success, otherwise an empty path when a non-directory path would be returned
* @post Returned directory path is created unless it is empty * @post Returned directory path is created unless it is empty
*/ */
const fs::path& GetDataDir(bool net_specific) const; const fs::path GetDataDir(bool net_specific) const;
// Helper function for LogArgs(). // Helper function for LogArgs().
void logArgsPrefix( void logArgsPrefix(