From a87244c93a22d3029c4271dd925a0f002c89239f Mon Sep 17 00:00:00 2001 From: "fix94.1" Date: Sun, 17 Jun 2012 11:12:07 +0000 Subject: [PATCH] -fixed possible codedump in cover downloader -added debug prints to see if crc32 is correctly cached --- source/menu/menu_download.cpp | 4 ++-- source/plugin/plugin.cpp | 35 +++++++++++++++++++++-------------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/source/menu/menu_download.cpp b/source/menu/menu_download.cpp index 6425bb9c..dd6dfe01 100644 --- a/source/menu/menu_download.cpp +++ b/source/menu/menu_download.cpp @@ -495,7 +495,7 @@ int CMenu::_coverDownloader(bool missingOnly) } 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()) { @@ -1218,7 +1218,7 @@ void CMenu::_download(string gameId) m_thrdStop = 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]; if(string(m_cf.getHdr()->path).find_last_of("/") != string::npos) diff --git a/source/plugin/plugin.cpp b/source/plugin/plugin.cpp index 4ca52205..5f900c63 100644 --- a/source/plugin/plugin.cpp +++ b/source/plugin/plugin.cpp @@ -297,24 +297,31 @@ string Plugin::GenerateCoverLink(dir_discHdr gameHeader, string url, Config &Che string cachedCRC = Checksums.getString("CHECKSUMS", gamePath, emptyString); char crc_string[9]; if(cachedCRC != emptyString) - snprintf(crc_string, sizeof(crc_string), "%s", cachedCRC.c_str()); - else if(strstr(gameHeader.path, ".zip") == NULL) { - snprintf(crc_string, sizeof(crc_string), "%08x", crc32file(gameHeader.path)); - Checksums.setString("CHECKSUMS", gamePath, crc_string); - Checksums.save(); + gprintf("CRC32 of %s is cached\n", gamePath); + snprintf(crc_string, sizeof(crc_string), "%s", cachedCRC.c_str()); } else { - u32 crc_buffer; - ifstream infile; - infile.open(gameHeader.path, ios::binary); - infile.seekg(0x0e, ios::beg); - infile.read((char*)&crc_buffer, 8); - infile.close(); - snprintf(crc_string, sizeof(crc_string), "%08x", SWAP32(crc_buffer)); - Checksums.setString("CHECKSUMS", gamePath, crc_string); - Checksums.save(); + gprintf("Generating CRC32 for %s\n", gamePath); + if(strstr(gameHeader.path, ".zip") == NULL) + { + snprintf(crc_string, sizeof(crc_string), "%08x", crc32file(gameHeader.path)); + Checksums.setString("CHECKSUMS", gamePath, crc_string); + Checksums.save(); + } + else + { + u32 crc_buffer; + ifstream infile; + infile.open(gameHeader.path, ios::binary); + infile.seekg(0x0e, ios::beg); + infile.read((char*)&crc_buffer, 8); + infile.close(); + snprintf(crc_string, sizeof(crc_string), "%08x", SWAP32(crc_buffer)); + Checksums.setString("CHECKSUMS", gamePath, crc_string); + Checksums.save(); + } } url.replace(url.find(TAG_GAME_ID), strlen(TAG_GAME_ID), upperCase(crc_string).c_str()); gprintf("URL: %s\n", url.c_str());