Tolerate empty gruntwork file

This prevents the server from failing to start if a gruntwork file
exists, but happens to be empty.
This commit is contained in:
dongresource 2023-03-13 05:18:27 +01:00
parent a9af8713bc
commit 743a39c125

View File

@ -1075,6 +1075,8 @@ void TableData::init() {
std::pair<json*, std::string>& table = tables[i];
fstream.open(settings::TDATADIR + "/" + table.second); // open file
if (!fstream.fail()) {
// tolerate empty gruntwork file
if (!(table.first == &gruntwork && fstream.peek() == std::ifstream::traits_type::eof()))
fstream >> *table.first; // load file contents into table
} else {
if (table.first != &gruntwork) { // gruntwork isn't critical