Skip to content

Commit 91e07cc

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#22591: Util: error if settings json exists, but is unreadable
2b07126 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: tACK 2b07126 ShaMan239: tACK 2b07126 prayank23: tACK bitcoin/bitcoin@2b07126 ryanofsky: Code review ACK 2b07126. Thanks for the fix! Note that PR #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: ACK 2b07126 📁 Tree-SHA512: 6f7f96ce8a13213d0335198a2245d127264495c877105058d1503252435915b332a6e55068ac21088f4c0c017d564689f4956213328d5bdee81d73711efc5511
2 parents 6490a3e + 2b07126 commit 91e07cc

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/util/settings.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,15 @@ bool ReadSettings(const fs::path& path, std::map<std::string, SettingsValue>& va
6060
values.clear();
6161
errors.clear();
6262

63+
// Ok for file to not exist
64+
if (!fs::exists(path)) return true;
65+
6366
fsbridge::ifstream file;
6467
file.open(path);
65-
if (!file.is_open()) return true; // Ok for file not to exist.
68+
if (!file.is_open()) {
69+
errors.emplace_back(strprintf("%s. Please check permissions.", path.string()));
70+
return false;
71+
}
6672

6773
SettingsValue in;
6874
if (!in.read(std::string{std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>()})) {

0 commit comments

Comments
 (0)