mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
Merge bitcoin/bitcoin#22591: Util: error if settings json exists, but is unreadable
2b071265c37da22f15769945fd159b50a14792a3 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 2b071265c37da22f15769945fd159b50a14792a3
ShaMan239:
tACK 2b071265c37da22f15769945fd159b50a14792a3
prayank23:
tACK 2b071265c3
ryanofsky:
Code review ACK 2b071265c37da22f15769945fd159b50a14792a3. 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:
ACK 2b071265c37da22f15769945fd159b50a14792a3 📁
Tree-SHA512: 6f7f96ce8a13213d0335198a2245d127264495c877105058d1503252435915b332a6e55068ac21088f4c0c017d564689f4956213328d5bdee81d73711efc5511
This commit is contained in:
parent
2966452a1b
commit
ab4405258e
@ -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…
Reference in New Issue
Block a user