- bugfix for CRC handling in connected menu

This commit is contained in:
Mark Vejvoda 2011-01-10 00:33:40 +00:00
parent 7bc6b603b9
commit 3dd6f244e6
3 changed files with 26 additions and 8 deletions

View File

@ -1819,6 +1819,9 @@ void MenuStateConnectedGame::FTPClient_CallbackEvent(string itemName, FTP_Client
fileFTPProgressList.erase(itemName);
safeMutexFTPProgress.ReleaseLock();
// Clear the CRC file Cache
Checksum::clearFileCache();
NetworkManager &networkManager= NetworkManager::getInstance();
ClientInterface* clientInterface= networkManager.getClientInterface();
const GameSettings *gameSettings = clientInterface->getGameSettings();
@ -1889,6 +1892,9 @@ void MenuStateConnectedGame::FTPClient_CallbackEvent(string itemName, FTP_Client
}
// END
// Clear the CRC file Cache
Checksum::clearFileCache();
// Reload tilesets for the UI
findDirs(Config::getInstance().getPathListForType(ptTilesets), tileSets);
}

View File

@ -37,7 +37,7 @@ private:
static std::map<string,int32> fileListCache;
void addSum(int32 value);
void addFileToSum(const string &path);
bool addFileToSum(const string &path);
public:
Checksum();
@ -49,6 +49,9 @@ public:
void addByte(int8 value);
void addString(const string &value);
void addFile(const string &path);
static void removeFileFromCache(const string file);
static void clearFileCache();
};
}}//end namespace

View File

@ -66,7 +66,7 @@ void Checksum::addFile(const string &path){
}
}
void Checksum::addFileToSum(const string &path){
bool Checksum::addFileToSum(const string &path){
// OLD SLOW FILE I/O
/*
@ -115,10 +115,10 @@ void Checksum::addFileToSum(const string &path){
free(data);
*/
bool fileExists = false;
FILE* file= fopen(path.c_str(), "rb");
if(file!=NULL) {
if(file != NULL) {
fileExists = true;
addString(lastFile(path));
bool isXMLFile = (EndsWith(path, ".xml") == true);
@ -162,12 +162,11 @@ void Checksum::addFileToSum(const string &path){
}
}
}
else
{
else {
throw runtime_error("Can not open file: " + path);
}
fclose(file);
return fileExists;
}
int32 Checksum::getSum() {
@ -200,4 +199,14 @@ int32 Checksum::getFileCount() {
return (int32)fileList.size();
}
void Checksum::removeFileFromCache(const string file) {
if(Checksum::fileListCache.find(file) != Checksum::fileListCache.end()) {
Checksum::fileListCache.erase(file);
}
}
void Checksum::clearFileCache() {
Checksum::fileListCache.clear();
}
}}//end namespace