From 630ff4a0d774b318833200db7e97cd4e271e5880 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Sat, 9 Mar 2024 12:24:18 +0100 Subject: [PATCH] Improved resilience to empty gamelist.xml files (they can now be updated instead of generating an error) --- es-app/src/GamelistFileParser.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/es-app/src/GamelistFileParser.cpp b/es-app/src/GamelistFileParser.cpp index 7958637ba..911fc3a9c 100644 --- a/es-app/src/GamelistFileParser.cpp +++ b/es-app/src/GamelistFileParser.cpp @@ -135,6 +135,12 @@ namespace GamelistFileParser return; } + if (Utils::FileSystem::getFileSize(xmlpath) == 0) { + LOG(LogWarning) << "GamelistFileParser::parseGamelist(): System \"" << system->getName() + << "\" has an empty gamelist.xml file"; + return; + } + #if defined(_WIN64) LOG(LogInfo) << "Parsing gamelist file \"" << Utils::String::replace(xmlpath, "/", "\\") << "\"..."; @@ -340,7 +346,8 @@ namespace GamelistFileParser const std::string& xmlReadPath {system->getGamelistPath(false)}; bool hasAlternativeEmulatorTag {false}; - if (Utils::FileSystem::exists(xmlReadPath)) { + if (Utils::FileSystem::exists(xmlReadPath) && + Utils::FileSystem::getFileSize(xmlReadPath) != 0) { // Parse an existing file first. #if defined(_WIN64)