Fix login on first startup and logout crash
parent
75dd96222e
commit
822995981e
|
@ -33,7 +33,12 @@ std::string WebDAV::getRootPath(bool encode) {
|
||||||
if (rootPath == "")
|
if (rootPath == "")
|
||||||
rootPath += "/";
|
rootPath += "/";
|
||||||
|
|
||||||
string rtc = NEXTCLOUD_ROOT_PATH + Util::getConfig<std::string>("UUID", "") + rootPath;
|
string user = Util::getConfig<std::string>("UUID", "");
|
||||||
|
if (user == "")
|
||||||
|
user = Util::getConfig<std::string>("username", "error");
|
||||||
|
|
||||||
|
string rtc = NEXTCLOUD_ROOT_PATH + user + rootPath;
|
||||||
|
|
||||||
if (encode) {
|
if (encode) {
|
||||||
Util::encodeUrl(rtc);
|
Util::encodeUrl(rtc);
|
||||||
rtc = std::regex_replace(rtc, std::regex("%2F"), "/");
|
rtc = std::regex_replace(rtc, std::regex("%2F"), "/");
|
||||||
|
@ -44,6 +49,8 @@ std::string WebDAV::getRootPath(bool encode) {
|
||||||
|
|
||||||
WebDAV::WebDAV()
|
WebDAV::WebDAV()
|
||||||
{
|
{
|
||||||
|
_fileHandler = std::shared_ptr<FileHandler>(new FileHandler());
|
||||||
|
|
||||||
if (iv_access(NEXTCLOUD_PATH.c_str(), W_OK) != 0)
|
if (iv_access(NEXTCLOUD_PATH.c_str(), W_OK) != 0)
|
||||||
iv_mkdir(NEXTCLOUD_PATH.c_str(), 0777);
|
iv_mkdir(NEXTCLOUD_PATH.c_str(), 0777);
|
||||||
|
|
||||||
|
@ -53,7 +60,6 @@ WebDAV::WebDAV()
|
||||||
_password = Util::accessConfig<string>(Action::IReadSecret,"password",{});
|
_password = Util::accessConfig<string>(Action::IReadSecret,"password",{});
|
||||||
_url = Util::accessConfig<string>(Action::IReadString, "url",{});
|
_url = Util::accessConfig<string>(Action::IReadString, "url",{});
|
||||||
_ignoreCert = Util::accessConfig<int>(Action::IReadInt, "ignoreCert",{});
|
_ignoreCert = Util::accessConfig<int>(Action::IReadInt, "ignoreCert",{});
|
||||||
_fileHandler = std::shared_ptr<FileHandler>(new FileHandler());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +114,9 @@ void WebDAV::logout(bool deleteFiles)
|
||||||
{
|
{
|
||||||
if (deleteFiles)
|
if (deleteFiles)
|
||||||
{
|
{
|
||||||
fs::remove_all(Util::accessConfig<string>(Action::IReadString, "storageLocation",{}) + "/" + Util::accessConfig<string>(Action::IReadString,"UUID",{}) + '/');
|
string filesPath = Util::accessConfig<string>(Action::IReadString, "storageLocation",{}) + "/" + Util::accessConfig<string>(Action::IReadString,"UUID",{}) + '/';
|
||||||
|
if (fs::exists(filesPath))
|
||||||
|
fs::remove_all(filesPath);
|
||||||
}
|
}
|
||||||
fs::remove(CONFIG_PATH.c_str());
|
fs::remove(CONFIG_PATH.c_str());
|
||||||
fs::remove((CONFIG_PATH + ".back.").c_str());
|
fs::remove((CONFIG_PATH + ".back.").c_str());
|
||||||
|
@ -201,8 +209,8 @@ vector<WebDAVItem> WebDAV::getDataStructure(const string &pathUrl)
|
||||||
|
|
||||||
string pathDecoded = tempItem.path;
|
string pathDecoded = tempItem.path;
|
||||||
Util::decodeUrl(pathDecoded);
|
Util::decodeUrl(pathDecoded);
|
||||||
tempItem.hide = _fileHandler->getHideState(tempItem.type, prefix,(pathDecoded), tempItem.title);
|
tempItem.hide = _fileHandler->getHideState(tempItem.type, prefix,pathDecoded, tempItem.title);
|
||||||
|
|
||||||
tempItems.push_back(tempItem);
|
tempItems.push_back(tempItem);
|
||||||
xmlItem = xmlItem.substr(end + endItem.length());
|
xmlItem = xmlItem.substr(end + endItem.length());
|
||||||
begin = xmlItem.find(beginItem);
|
begin = xmlItem.find(beginItem);
|
||||||
|
@ -248,7 +256,6 @@ string WebDAV::propfind(const string &pathUrl)
|
||||||
string readBuffer;
|
string readBuffer;
|
||||||
CURLcode res;
|
CURLcode res;
|
||||||
CURL *curl = curl_easy_init();
|
CURL *curl = curl_easy_init();
|
||||||
Log::writeInfoLog("Path: " + pathUrl);
|
|
||||||
|
|
||||||
if (curl)
|
if (curl)
|
||||||
{
|
{
|
||||||
|
|
|
@ -432,7 +432,7 @@ int EventHandler::pointerHandler(const int type, const int par1, const int par2)
|
||||||
{
|
{
|
||||||
ShowHourglassForce();
|
ShowHourglassForce();
|
||||||
|
|
||||||
std::vector<WebDAVItem> currentWebDAVItems = _webDAV.login(_loginView->getURL(), _loginView->getUsername(), _loginView->getPassword(), _loginView->getIgnoreCert());;
|
std::vector<WebDAVItem> currentWebDAVItems = _webDAV.login(_loginView->getURL(), _loginView->getUsername(), _loginView->getPassword(), _loginView->getIgnoreCert());
|
||||||
if (currentWebDAVItems.empty())
|
if (currentWebDAVItems.empty())
|
||||||
{
|
{
|
||||||
Message(ICON_ERROR, "Error", "Login failed.", 1000);
|
Message(ICON_ERROR, "Error", "Login failed.", 1000);
|
||||||
|
|
|
@ -93,7 +93,6 @@ bool FileHandler::excludeFile(std::string filename) {
|
||||||
if (_useRegex) {
|
if (_useRegex) {
|
||||||
try {
|
try {
|
||||||
bool t = std::regex_match(filename, _regex) != _invertMatch;
|
bool t = std::regex_match(filename, _regex) != _invertMatch;
|
||||||
string ta = t ? "true" : "false";
|
|
||||||
return t;
|
return t;
|
||||||
} catch (std::regex_error err) {
|
} catch (std::regex_error err) {
|
||||||
string errM = err.what();
|
string errM = err.what();
|
||||||
|
|
Loading…
Reference in New Issue