From 743a39c1254c880a525864c0981a2bae15cf8321 Mon Sep 17 00:00:00 2001 From: dongresource Date: Mon, 13 Mar 2023 05:18:27 +0100 Subject: [PATCH] Tolerate empty gruntwork file This prevents the server from failing to start if a gruntwork file exists, but happens to be empty. --- src/TableData.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/TableData.cpp b/src/TableData.cpp index daa5dc0..0a1310f 100644 --- a/src/TableData.cpp +++ b/src/TableData.cpp @@ -1075,7 +1075,9 @@ void TableData::init() { std::pair& 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;