From c673f06eb03348d0dfa9ee8e3b468297749c0df6 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Sat, 6 Nov 2021 21:21:41 +0100 Subject: [PATCH] Improved the handling of invalid scraper configuration file entries. --- es-app/src/scrapers/Scraper.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/es-app/src/scrapers/Scraper.cpp b/es-app/src/scrapers/Scraper.cpp index 3193e4dca..fdb53a8f7 100644 --- a/es-app/src/scrapers/Scraper.cpp +++ b/es-app/src/scrapers/Scraper.cpp @@ -32,7 +32,14 @@ const std::map scraper_request_func std::unique_ptr startScraperSearch(const ScraperSearchParams& params) { - const std::string& name = Settings::getInstance()->getString("Scraper"); + std::string name = Settings::getInstance()->getString("Scraper"); + // Handle a potentially invalid entry in the configuration file. + if (name != "screenscraper" && name != "thegamesdb") { + name = "screenscraper"; + Settings::getInstance()->setString("Scraper", name); + Settings::getInstance()->saveFile(); + } + std::unique_ptr handle(new ScraperSearchHandle()); // Check if the scraper in the settings still exists as a registered scraping source. @@ -80,15 +87,8 @@ std::vector getScraperList() bool isValidConfiguredScraper() { - std::string scraper = Settings::getInstance()->getString("Scraper"); - // Handle a potentially invalid entry in the configuration file. - if (scraper != "screenscraper" && scraper != "thegamesdb") { - scraper = "screenscraper"; - Settings::getInstance()->setString("Scraper", scraper); - Settings::getInstance()->saveFile(); - } - - return scraper_request_funcs.find(scraper) != scraper_request_funcs.end(); + const std::string& name = Settings::getInstance()->getString("Scraper"); + return scraper_request_funcs.find(name) != scraper_request_funcs.end(); } void ScraperSearchHandle::update()