added Error msg on failed curl call

pull/23/head
JuanJakobo 2021-02-15 21:53:15 +01:00
parent 8c0a1d3218
commit bfa3ad9751
1 changed files with 14 additions and 8 deletions

View File

@ -191,6 +191,10 @@ void Nextcloud::downloadItem(vector<Item> &tempItems, int itemID)
break; break;
} }
} }
else
{
Message(ICON_ERROR, "Error", ("An curl error occured (Error Code: " + Util::valueToString(res) + ").").c_str(), 4000);
}
} }
} }
@ -206,7 +210,7 @@ bool Nextcloud::downloadFolder(vector<Item> &tempItems, int itemID)
for (auto i = 1; i < tempItems.size(); i++) for (auto i = 1; i < tempItems.size(); i++)
{ {
Log::writeLog("Item: " + tempItems.at(i).getPath()); Log::writeLog("Item: " + tempItems.at(i).getPath());
downloadFolder(tempItems,i); downloadFolder(tempItems, i);
} }
} }
else else
@ -216,7 +220,7 @@ bool Nextcloud::downloadFolder(vector<Item> &tempItems, int itemID)
downloadItem(tempItems, itemID); downloadItem(tempItems, itemID);
} }
return true; return true;
} }
void Nextcloud::download(int itemID) void Nextcloud::download(int itemID)
@ -228,13 +232,13 @@ void Nextcloud::download(int itemID)
return; return;
} }
this->downloadFolder(_items,itemID); this->downloadFolder(_items, itemID);
} }
bool Nextcloud::removeItem(int itemID) bool Nextcloud::removeItem(int itemID)
{ {
Log::writeLog("removing file " + _items.at(itemID).getPath()); Log::writeLog("removing file " + _items.at(itemID).getPath());
if(!_items.at(itemID).removeFile()) if (!_items.at(itemID).removeFile())
return false; return false;
return true; return true;
@ -268,7 +272,6 @@ vector<Item> Nextcloud::getDataStructure(const string &pathUrl, const string &Us
Log::writeLog("Starting download of DataStructure"); Log::writeLog("Starting download of DataStructure");
string readBuffer; string readBuffer;
CURLcode res; CURLcode res;
CURL *curl = curl_easy_init(); CURL *curl = curl_easy_init();
@ -297,7 +300,7 @@ vector<Item> Nextcloud::getDataStructure(const string &pathUrl, const string &Us
switch (response_code) switch (response_code)
{ {
case 404: case 404:
Message(ICON_ERROR, "Error", "The nextcloud URL seems to be incorrect. You can look up the WebDav URL in the files app->seetings. (The nextcloud URL is the part till \"/remote.php...\".)" , 4000); Message(ICON_ERROR, "Error", "The nextcloud URL seems to be incorrect. You can look up the WebDav URL in the files app->seetings. (The nextcloud URL is the part till \"/remote.php...\".)", 4000);
break; break;
case 401: case 401:
Message(ICON_ERROR, "Error", "Username/password incorrect.", 4000); Message(ICON_ERROR, "Error", "Username/password incorrect.", 4000);
@ -351,6 +354,10 @@ vector<Item> Nextcloud::getDataStructure(const string &pathUrl, const string &Us
return getOfflineStructure(pathUrl); return getOfflineStructure(pathUrl);
} }
} }
else
{
Message(ICON_ERROR, "Error", ("An curl error occured (Error Code: " + Util::valueToString(res) + ").").c_str(), 4000);
}
} }
return {}; return {};
} }
@ -405,7 +412,7 @@ vector<Item> Nextcloud::readInXML(string xml)
{ {
end = xml.find(endItem); end = xml.find(endItem);
tempItems.push_back(xml.substr(begin,end)); tempItems.push_back(xml.substr(begin, end));
xml = xml.substr(end + endItem.length()); xml = xml.substr(end + endItem.length());
@ -413,7 +420,6 @@ vector<Item> Nextcloud::readInXML(string xml)
} }
return tempItems; return tempItems;
} }
string Nextcloud::getLocalPath(string path) string Nextcloud::getLocalPath(string path)