create localPath variable also for folders

pull/23/head
JuanJakobo 2021-02-22 16:52:17 +01:00
parent 7aaf79e2e7
commit 440fbefa43
3 changed files with 13 additions and 8 deletions

View File

@ -26,22 +26,21 @@ Item::Item(const string &xmlItem)
_lastEditDate = Util::getXMLAttribute(xmlItem, "d:getlastmodified");
_title = _path;
_localPath = Nextcloud::getLocalPath(_path);
if (_path.back() == '/')
{
_type = IFOLDER;
_localPath = _localPath.substr(0, _localPath.length() - 1);
_type = Itemtype::IFOLDER;
_title = _title.substr(0, _path.length() - 1);
_size = atof(Util::getXMLAttribute(xmlItem, "d:quota-used-bytes").c_str());
}
else
{
_type = IFILE;
_type = Itemtype::IFILE;
_size = atof(Util::getXMLAttribute(xmlItem, "d:getcontentlength").c_str());
_fileType = Util::getXMLAttribute(xmlItem, "d:getcontenttype");
//set local path and test if exists
_localPath = Nextcloud::getLocalPath(_path);
if (iv_access(_localPath.c_str(), W_OK) != 0)
{
_state = FileState::ICLOUD;

View File

@ -46,7 +46,7 @@ public:
* @param localPath path where the file is placed
* @param FileState state of the file
*/
Item(const string &localPath, FileState state);
Item(const string &localPath, FileState state, Itemtype type);
/**
* Tries to open the item by checking the file format and then executes the fitting action

View File

@ -511,8 +511,14 @@ void Nextcloud::getLocalFileStructure(vector<Item> &tempItems, const string &loc
}
if (!found)
{
//TODO push to different items list and then ask if shall be deleted later on? --> just in case of folder sync
tempItems.push_back(Item(fullFileName, FileState::ILOCAL));
if (isDirectory)
{
tempItems.push_back(Item(fullFileName, FileState::ILOCAL, Itemtype::IFOLDER));
}
else
{
tempItems.push_back(Item(fullFileName, FileState::ILOCAL, Itemtype::IFILE));
}
}
}
closedir(dir);