mirror of
https://github.com/glest/glest-source.git
synced 2025-08-24 08:52:49 +02:00
- some ftp bugfixes and cleanup on ftp client that have failed transfers
This commit is contained in:
@@ -131,6 +131,7 @@ bool StartsWith(const std::string &str, const std::string &key);
|
|||||||
bool EndsWith(const string &str, const string& key);
|
bool EndsWith(const string &str, const string& key);
|
||||||
|
|
||||||
string replaceAll(string& context, const string& from, const string& to);
|
string replaceAll(string& context, const string& from, const string& to);
|
||||||
|
void removeFolder(const string path);
|
||||||
|
|
||||||
int getScreenW();
|
int getScreenW();
|
||||||
int getScreenH();
|
int getScreenH();
|
||||||
|
@@ -416,6 +416,7 @@ int ftpSelect(int poll)
|
|||||||
if(poll)
|
if(poll)
|
||||||
{
|
{
|
||||||
struct timeval t = {0};
|
struct timeval t = {0};
|
||||||
|
t.tv_usec = 10000;
|
||||||
return select(maxSockNr+1, &signaledSockets, NULL, NULL, &t);
|
return select(maxSockNr+1, &signaledSockets, NULL, NULL, &t);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -447,6 +447,7 @@ int ftpSelect(int poll)
|
|||||||
if(poll)
|
if(poll)
|
||||||
{
|
{
|
||||||
struct timeval t = {0};
|
struct timeval t = {0};
|
||||||
|
t.tv_usec = 10000;
|
||||||
return select(maxSockNr+1, &signaledSockets, NULL, NULL, &t);
|
return select(maxSockNr+1, &signaledSockets, NULL, NULL, &t);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -335,22 +335,38 @@ bool isdir(const char *path)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
void removeFolder(const string path) {
|
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;
|
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) {
|
for(int i = results.size() -1; i >= 0; --i) {
|
||||||
string item = results[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());
|
rmdir(item.c_str());
|
||||||
}
|
}
|
||||||
else {
|
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());
|
unlink(item.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
bool StartsWith(const std::string &str, const std::string &key) {
|
bool StartsWith(const std::string &str, const std::string &key) {
|
||||||
return str.find(key) == 0;
|
return str.find(key) == 0;
|
||||||
|
@@ -228,7 +228,7 @@ FTP_Client_ResultType FTPClientThread::getMapFromServer(string mapFileName, stri
|
|||||||
CURLcode res = curl_easy_perform(curl);
|
CURLcode res = curl_easy_perform(curl);
|
||||||
if(CURLE_OK != res) {
|
if(CURLE_OK != res) {
|
||||||
// we failed
|
// we failed
|
||||||
printf("curl FAILED with: %d\n", res);
|
printf("curl FAILED with: %d [%s]\n", res,curl_easy_strerror(res));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
result = ftp_crt_SUCCESS;
|
result = ftp_crt_SUCCESS;
|
||||||
@@ -383,10 +383,11 @@ FTP_Client_ResultType FTPClientThread::getTilesetFromServer(string tileSetName,
|
|||||||
|
|
||||||
if(CURLE_OK != res) {
|
if(CURLE_OK != res) {
|
||||||
// we failed
|
// we failed
|
||||||
printf("curl FAILED with: %d\n", res);
|
printf("curl FAILED with: %d [%s]\n", res,curl_easy_strerror(res));
|
||||||
|
|
||||||
if(destRootFolder != "") {
|
if(destRootFolder != "") {
|
||||||
unlink(destRootFolder.c_str());
|
//unlink(destRootFolder.c_str());
|
||||||
|
removeFolder(destRootFolder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@@ -130,7 +130,7 @@ void FTPServerThread::execute() {
|
|||||||
while(this->getQuitStatus() == false) {
|
while(this->getQuitStatus() == false) {
|
||||||
int processedWork = ftpExecute();
|
int processedWork = ftpExecute();
|
||||||
if(processedWork == 0) {
|
if(processedWork == 0) {
|
||||||
sleep(25);
|
//sleep(25);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ftpShutdown();
|
ftpShutdown();
|
||||||
|
Reference in New Issue
Block a user