mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 02:33:24 -03:00
Merge bitcoin/bitcoin#22591: Util: error if settings json exists, but is unreadable
2b071265c3
error if settings.json exists, but is unreadable (Tyler Chambers) Pull request description: If settings.json exists, but is unreadable, we should error instead of overwriting. Fixes #22571 ACKs for top commit: Zero-1729: tACK2b071265c3
ShaMan239: tACK2b071265c3
prayank23: tACK2b071265c3
ryanofsky: Code review ACK2b071265c3
. Thanks for the fix! Note that PR https://github.com/bitcoin-core/gui/pull/379 will change the appearance of dialogs shown in screenshots above. So it could be interesting to test the two PRs together (but current testing seems more than sufficient) theStack: ACK2b071265c3
📁 Tree-SHA512: 6f7f96ce8a13213d0335198a2245d127264495c877105058d1503252435915b332a6e55068ac21088f4c0c017d564689f4956213328d5bdee81d73711efc5511
This commit is contained in:
commit
91e07cc50d
1 changed files with 7 additions and 1 deletions
|
@ -60,9 +60,15 @@ bool ReadSettings(const fs::path& path, std::map<std::string, SettingsValue>& va
|
|||
values.clear();
|
||||
errors.clear();
|
||||
|
||||
// Ok for file to not exist
|
||||
if (!fs::exists(path)) return true;
|
||||
|
||||
fsbridge::ifstream file;
|
||||
file.open(path);
|
||||
if (!file.is_open()) return true; // Ok for file not to exist.
|
||||
if (!file.is_open()) {
|
||||
errors.emplace_back(strprintf("%s. Please check permissions.", path.string()));
|
||||
return false;
|
||||
}
|
||||
|
||||
SettingsValue in;
|
||||
if (!in.read(std::string{std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>()})) {
|
||||
|
|
Loading…
Add table
Reference in a new issue