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
1 changed files with 3 additions and 1 deletions

View File

@ -1075,7 +1075,9 @@ void TableData::init() {
std::pair<json*, std::string>& table = tables[i];
fstream.open(settings::TDATADIR + "/" + table.second); // open file
if (!fstream.fail()) {
fstream >> *table.first; // load file contents into table
// 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
std::cerr << "[FATAL] Critical tdata file missing: " << table.second << std::endl;