Fixed an issue where duplicate ScreenScraper game IDs were sometimes not removed from the search results

This commit is contained in:
Leon Styhre 2023-10-24 20:32:19 +02:00
parent e363b0a605
commit 2de3897c8a

View file

@ -313,13 +313,16 @@ void ScreenScraperRequest::process(const std::unique_ptr<HttpReq>& req,
// If there are multiple platforms defined for the system, then it's possible that the scraper
// service will return the same results for each platform, so we need to remove such duplicates.
if (results.size() > 1) {
const std::string gameID {results.front().gameID};
for (auto it = results.cbegin() + 1; it != results.cend();) {
if ((*it).gameID == gameID) {
std::vector<std::string> gameIDs;
for (auto it = results.cbegin(); it != results.cend();) {
if (std::find(gameIDs.begin(), gameIDs.end(), (*it).gameID) != gameIDs.end()) {
LOG(LogDebug)
<< "ScreenScraperRequest::process(): Removed duplicate entry for game ID "
<< (*it).gameID;
it = results.erase(it);
LOG(LogDebug) << "ScreenScraperRequest::process(): Removed duplicate entry";
}
else {
gameIDs.emplace_back((*it).gameID);
++it;
}
}