Skip to content

Commit

Permalink
error if settings.json exists, but is unreadable
Browse files Browse the repository at this point in the history
Github-Pull: bitcoin#22591
Rebased-From: 2b07126
  • Loading branch information
tylerchambers authored and luke-jr committed Sep 20, 2021
1 parent 831675c commit 0beb4b7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/util/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>()})) {
Expand Down

0 comments on commit 0beb4b7

Please sign in to comment.