- some ftp bugfixes and cleanup on ftp client that have failed transfers

This commit is contained in:
Mark Vejvoda 2011-01-09 05:49:59 +00:00
parent 31be2df752
commit 912188679c
6 changed files with 31 additions and 11 deletions

View File

@ -131,6 +131,7 @@ bool StartsWith(const std::string &str, const std::string &key);
bool EndsWith(const string &str, const string& key);
string replaceAll(string& context, const string& from, const string& to);
void removeFolder(const string path);
int getScreenW();
int getScreenH();

View File

@ -415,7 +415,8 @@ int ftpSelect(int poll)
if(poll)
{
struct timeval t = {0};
struct timeval t = {0};
t.tv_usec = 10000;
return select(maxSockNr+1, &signaledSockets, NULL, NULL, &t);
}
else

View File

@ -446,7 +446,8 @@ int ftpSelect(int poll)
if(poll)
{
struct timeval t = {0};
struct timeval t = {0};
t.tv_usec = 10000;
return select(maxSockNr+1, &signaledSockets, NULL, NULL, &t);
}
else

View File

@ -335,22 +335,38 @@ bool isdir(const char *path)
return ret;
}
/*
void removeFolder(const string path) {
path += "*";
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path [%s]\n",__FILE__,__FUNCTION__,__LINE__,path.c_str());
string deletePath = path + "*";
vector<string> results;
findAll(path, vector<string> &results, false, false);
findAll(deletePath, results, false, false);
// First delete files
for(int i = results.size() -1; i >= 0; --i) {
string item = results[i];
if(isdir(item) == true) {
if(isdir(item.c_str()) == true) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] item [%s]\n",__FILE__,__FUNCTION__,__LINE__,item.c_str());
rmdir(item.c_str());
}
else {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] item [%s]\n",__FILE__,__FUNCTION__,__LINE__,item.c_str());
unlink(item.c_str());
}
}
// Now delete folders
for(int i = results.size() -1; i >= 0; --i) {
string item = results[i];
if(isdir(item.c_str()) == true) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] item [%s]\n",__FILE__,__FUNCTION__,__LINE__,item.c_str());
rmdir(item.c_str());
}
else {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] item [%s]\n",__FILE__,__FUNCTION__,__LINE__,item.c_str());
unlink(item.c_str());
}
}
}
*/
bool StartsWith(const std::string &str, const std::string &key) {
return str.find(key) == 0;

View File

@ -228,7 +228,7 @@ FTP_Client_ResultType FTPClientThread::getMapFromServer(string mapFileName, stri
CURLcode res = curl_easy_perform(curl);
if(CURLE_OK != res) {
// we failed
printf("curl FAILED with: %d\n", res);
printf("curl FAILED with: %d [%s]\n", res,curl_easy_strerror(res));
}
else {
result = ftp_crt_SUCCESS;
@ -383,10 +383,11 @@ FTP_Client_ResultType FTPClientThread::getTilesetFromServer(string tileSetName,
if(CURLE_OK != res) {
// we failed
printf("curl FAILED with: %d\n", res);
printf("curl FAILED with: %d [%s]\n", res,curl_easy_strerror(res));
if(destRootFolder != "") {
unlink(destRootFolder.c_str());
//unlink(destRootFolder.c_str());
removeFolder(destRootFolder);
}
}
else {

View File

@ -130,7 +130,7 @@ void FTPServerThread::execute() {
while(this->getQuitStatus() == false) {
int processedWork = ftpExecute();
if(processedWork == 0) {
sleep(25);
//sleep(25);
}
}
ftpShutdown();