-fixed possible codedump in cover downloader

-added debug prints to see if crc32 is correctly cached
This commit is contained in:
fix94.1 2012-06-17 11:12:07 +00:00
parent 8f16156768
commit a87244c93a
2 changed files with 23 additions and 16 deletions

View File

@ -495,7 +495,7 @@ int CMenu::_coverDownloader(bool missingOnly)
} }
Config m_checksums; Config m_checksums;
m_checksums.load(fmt("%s/" PLUGIN_CRCS_FILENAME, m_settingsDir.c_str())); m_checksums.load(fmt("%s/%s", m_settingsDir.c_str(), PLUGIN_CRCS_FILENAME));
if (m_coverDLGameId.empty()) if (m_coverDLGameId.empty())
{ {
@ -1218,7 +1218,7 @@ void CMenu::_download(string gameId)
m_thrdStop = false; m_thrdStop = false;
m_thrdMessageAdded = false; m_thrdMessageAdded = false;
if((m_cf.getHdr()->type == TYPE_PLUGIN) && gameId.size()) if(gameId.size() && m_cf.getHdr()->type == TYPE_PLUGIN)
{ {
char gamePath[256]; char gamePath[256];
if(string(m_cf.getHdr()->path).find_last_of("/") != string::npos) if(string(m_cf.getHdr()->path).find_last_of("/") != string::npos)

View File

@ -297,8 +297,14 @@ string Plugin::GenerateCoverLink(dir_discHdr gameHeader, string url, Config &Che
string cachedCRC = Checksums.getString("CHECKSUMS", gamePath, emptyString); string cachedCRC = Checksums.getString("CHECKSUMS", gamePath, emptyString);
char crc_string[9]; char crc_string[9];
if(cachedCRC != emptyString) if(cachedCRC != emptyString)
{
gprintf("CRC32 of %s is cached\n", gamePath);
snprintf(crc_string, sizeof(crc_string), "%s", cachedCRC.c_str()); snprintf(crc_string, sizeof(crc_string), "%s", cachedCRC.c_str());
else if(strstr(gameHeader.path, ".zip") == NULL) }
else
{
gprintf("Generating CRC32 for %s\n", gamePath);
if(strstr(gameHeader.path, ".zip") == NULL)
{ {
snprintf(crc_string, sizeof(crc_string), "%08x", crc32file(gameHeader.path)); snprintf(crc_string, sizeof(crc_string), "%08x", crc32file(gameHeader.path));
Checksums.setString("CHECKSUMS", gamePath, crc_string); Checksums.setString("CHECKSUMS", gamePath, crc_string);
@ -316,6 +322,7 @@ string Plugin::GenerateCoverLink(dir_discHdr gameHeader, string url, Config &Che
Checksums.setString("CHECKSUMS", gamePath, crc_string); Checksums.setString("CHECKSUMS", gamePath, crc_string);
Checksums.save(); Checksums.save();
} }
}
url.replace(url.find(TAG_GAME_ID), strlen(TAG_GAME_ID), upperCase(crc_string).c_str()); url.replace(url.find(TAG_GAME_ID), strlen(TAG_GAME_ID), upperCase(crc_string).c_str());
gprintf("URL: %s\n", url.c_str()); gprintf("URL: %s\n", url.c_str());
return url; return url;