This PR is a continuation of bitcoin/bitcoin#24265 and bitcoin/bitcoin#24306.
Now the following command-line arguments / configure options been read with the GetPathArg method:
-conf, alsoincludeconfvalues been normalized-rpccookiefile
This PR is a continuation of bitcoin/bitcoin#24265 and bitcoin/bitcoin#24306.
Now the following command-line arguments / configure options been read with the GetPathArg method:
-conf, also includeconf values been normalized-rpccookiefileFriendly ping @ryanofsky @prusnak
Concept ACK
concept ack
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--174a7506f384e20aa4161008e828411d-->
No conflicts as of last run.
948 | @@ -949,7 +949,7 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys) 949 | const size_t default_includes = add_includes({}); 950 | 951 | for (const std::string& conf_file_name : conf_file_names) { 952 | - std::ifstream conf_file_stream{GetConfigFile(conf_file_name)}; 953 | + std::ifstream conf_file_stream{GetConfigFile(fs::NormalizedPathFromString(conf_file_name))};
In commit "util, refactor: Use GetPathArg to read "-conf" value" (88f48f39f84ae52f85819321dddf6e6bd9381be2)
I think it would be better to use fs::PathFromString not fs::NormalizedPathFromString here
154 | @@ -155,6 +155,18 @@ static inline path PathFromString(const std::string& string) 155 | #endif 156 | } 157 | 158 | +/** 159 | + * Convert byte string to path object which in turn has been 160 | + * normalized, with redundant "." and ".." path components 161 | + * and trailing separators removed. 162 | + */ 163 | +static inline path NormalizedPathFromString(std::string string)
In commit "util, refactor: Add fs::NormalizedPathFromString function" (bc9ea0d3506610c0613bc27ee0c5c9d56e91092a)
I think it would probably be better not to add this function because:
PathFromString and u8path), and introducing a third function will probably add confusion. Especially when there is no explanation about when this function is supposed to be favored or avoided compared to the other ones.static inline path NormalizedPath(std::path path)
{
fs::path result = path.lexically_normal();
// Remove trailing slash, if present.
return result.has_filename() ? result : result.parent_path();
}
Code review ACK 92aacdabf9b66bb7e030d80e842870dfcd1f9709, but it would be good to consider suggestions related to the NormalizedPathFromString function.
Also "includeconf" values been normalized.
Removes unhelpful noise/verbosity.
See: https://github.com/bitcoin/bitcoin/pull/24306#discussion_r809363741
Code Review ACK b01f336708019f8c8274ea701d3446e4123e7af2
This is a nice cleanup and it is correct to expand the usage of GetPathArg to conf settings that are being passed a path, obviously :)
Code review ACK b01f336708019f8c8274ea701d3446e4123e7af. Changes since last review: just dropping first commit (NormalizedPathFromString) as suggested