Set status to IDOWNLOADED if sync has been used
parent
339db51d3d
commit
3aaa1ada0f
|
@ -24,7 +24,8 @@ enum FileState
|
||||||
ICLOUD,
|
ICLOUD,
|
||||||
ISYNCED,
|
ISYNCED,
|
||||||
IOUTSYNCED,
|
IOUTSYNCED,
|
||||||
ILOCAL
|
ILOCAL,
|
||||||
|
IDOWNLOADED
|
||||||
};
|
};
|
||||||
|
|
||||||
struct WebDAVItem : Entry{
|
struct WebDAVItem : Entry{
|
||||||
|
|
|
@ -474,6 +474,7 @@ void EventHandler::openFolder()
|
||||||
case FileState::ICLOUD:
|
case FileState::ICLOUD:
|
||||||
currentWebDAVItems = _webDAV.getDataStructure(_webDAVView->getCurrentEntry().path);
|
currentWebDAVItems = _webDAV.getDataStructure(_webDAVView->getCurrentEntry().path);
|
||||||
case FileState::ISYNCED:
|
case FileState::ISYNCED:
|
||||||
|
case FileState::IDOWNLOADED:
|
||||||
{
|
{
|
||||||
if (!currentWebDAVItems.empty())
|
if (!currentWebDAVItems.empty())
|
||||||
updateItems(currentWebDAVItems);
|
updateItems(currentWebDAVItems);
|
||||||
|
@ -492,8 +493,6 @@ void EventHandler::openFolder()
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -602,12 +601,15 @@ void EventHandler::downloadFolder(vector<WebDAVItem> &items, int itemID)
|
||||||
{
|
{
|
||||||
UpdateProgressbar(("Syncing folder" + path).c_str(), 0);
|
UpdateProgressbar(("Syncing folder" + path).c_str(), 0);
|
||||||
tempItems = _webDAV.getDataStructure(path);
|
tempItems = _webDAV.getDataStructure(path);
|
||||||
|
items.at(itemID).state = FileState::IDOWNLOADED;
|
||||||
updateItems(tempItems);
|
updateItems(tempItems);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FileState::ISYNCED:
|
case FileState::ISYNCED:
|
||||||
{
|
{
|
||||||
tempItems = _sqllite.getItemsChildren(path);
|
tempItems = _sqllite.getItemsChildren(path);
|
||||||
|
items.at(itemID).state = FileState::IDOWNLOADED;
|
||||||
|
_sqllite.updateState(items.at(itemID).path,items.at(itemID).state);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FileState::ILOCAL:
|
case FileState::ILOCAL:
|
||||||
|
@ -628,6 +630,8 @@ void EventHandler::downloadFolder(vector<WebDAVItem> &items, int itemID)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!tempItems.empty())
|
if(!tempItems.empty())
|
||||||
|
@ -665,7 +669,7 @@ void EventHandler::downloadFolder(vector<WebDAVItem> &items, int itemID)
|
||||||
Log::writeInfoLog("started download of " + items.at(itemID).path + " to " + items.at(itemID).localPath);
|
Log::writeInfoLog("started download of " + items.at(itemID).path + " to " + items.at(itemID).localPath);
|
||||||
if (_webDAV.get(items.at(itemID))) {
|
if (_webDAV.get(items.at(itemID))) {
|
||||||
items.at(itemID).state = FileState::ISYNCED;
|
items.at(itemID).state = FileState::ISYNCED;
|
||||||
_sqllite.updateState(items.at(itemID).path,FileState::ISYNCED);
|
_sqllite.updateState(items.at(itemID).path,items.at(itemID).state);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -697,15 +701,16 @@ void EventHandler::startDownload()
|
||||||
if (_webDAV.get(_webDAVView->getCurrentEntry()))
|
if (_webDAV.get(_webDAVView->getCurrentEntry()))
|
||||||
{
|
{
|
||||||
_webDAVView->getCurrentEntry().state = FileState::ISYNCED;
|
_webDAVView->getCurrentEntry().state = FileState::ISYNCED;
|
||||||
_sqllite.updateState(_webDAVView->getCurrentEntry().path,FileState::ISYNCED);
|
_sqllite.updateState(_webDAVView->getCurrentEntry().path,_webDAVView->getCurrentEntry().state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vector<WebDAVItem> currentItems = _sqllite.getItemsChildren(_webDAVView->getCurrentEntry().path);
|
vector<WebDAVItem> currentItems = _sqllite.getItemsChildren(_webDAVView->getCurrentEntry().path);
|
||||||
this->downloadFolder(currentItems, 0);
|
this->downloadFolder(currentItems, 0);
|
||||||
|
_webDAVView->getCurrentEntry().state = FileState::IDOWNLOADED;
|
||||||
|
_sqllite.updateState(_webDAVView->getCurrentEntry().path,_webDAVView->getCurrentEntry().state);
|
||||||
UpdateProgressbar("Download completed", 100);
|
UpdateProgressbar("Download completed", 100);
|
||||||
_webDAVView->getCurrentEntry().state = FileState::ISYNCED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO implement
|
//TODO implement
|
||||||
|
@ -718,7 +723,7 @@ void EventHandler::updateItems(vector<WebDAVItem> &items)
|
||||||
{
|
{
|
||||||
for(auto &item : items)
|
for(auto &item : items)
|
||||||
{
|
{
|
||||||
//ICloud if is not found
|
//returns ICloud if is not found
|
||||||
item.state = _sqllite.getState(item.path);
|
item.state = _sqllite.getState(item.path);
|
||||||
|
|
||||||
if (item.type == Itemtype::IFILE)
|
if (item.type == Itemtype::IFILE)
|
||||||
|
@ -731,13 +736,19 @@ void EventHandler::updateItems(vector<WebDAVItem> &items)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (iv_access(item.localPath.c_str(), W_OK) != 0)
|
if (iv_access(item.localPath.c_str(), W_OK) != 0)
|
||||||
|
{
|
||||||
|
//TODO here if status is downloadad try aginst the DB all kids
|
||||||
|
if(items.at(0).state != FileState::IDOWNLOADED)
|
||||||
|
items.at(0).state = FileState::IOUTSYNCED;
|
||||||
iv_mkdir(item.localPath.c_str(), 0777);
|
iv_mkdir(item.localPath.c_str(), 0777);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
if (_sqllite.getEtag(item.path).compare(item.etag) != 0)
|
if (_sqllite.getEtag(item.path).compare(item.etag) != 0)
|
||||||
item.state = (item.state == FileState::ISYNCED) ? FileState::IOUTSYNCED : FileState::ICLOUD;
|
item.state = (item.state == FileState::ISYNCED || item.state == FileState::IDOWNLOADED) ? FileState::IOUTSYNCED : FileState::ICLOUD;
|
||||||
}
|
}
|
||||||
items.at(0).state = FileState::ISYNCED;
|
if(items.at(0).state != FileState::IDOWNLOADED)
|
||||||
|
items.at(0).state = FileState::ISYNCED;
|
||||||
_sqllite.saveItemsChildren(items);
|
_sqllite.saveItemsChildren(items);
|
||||||
|
|
||||||
//TODO sync delete when not parentPath existend --> "select * from metadata where parentPath NOT IN (Select
|
//TODO sync delete when not parentPath existend --> "select * from metadata where parentPath NOT IN (Select
|
||||||
|
|
|
@ -29,27 +29,26 @@ void WebDAVViewEntry::draw(const ifont *entryFont, const ifont *entryFontBold, i
|
||||||
DrawTextRect(_position.x, _position.y, _position.w, heightOfTitle, _entry.title.c_str(), ALIGN_LEFT);
|
DrawTextRect(_position.x, _position.y, _position.w, heightOfTitle, _entry.title.c_str(), ALIGN_LEFT);
|
||||||
SetFont(entryFont, BLACK);
|
SetFont(entryFont, BLACK);
|
||||||
|
|
||||||
if (_entry.state == FileState::ILOCAL)
|
|
||||||
{
|
|
||||||
DrawTextRect(_position.x, _position.y + heightOfTitle + fontHeight, _position.w, fontHeight, "Local", ALIGN_RIGHT);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
int height = 0;
|
int height = 0;
|
||||||
std::string text = {};
|
std::string text = {};
|
||||||
if (_entry.type == Itemtype::IFILE)
|
if (_entry.type == Itemtype::IFILE)
|
||||||
{
|
{
|
||||||
height = fontHeight;
|
height = fontHeight;
|
||||||
DrawTextRect(_position.x, _position.y + heightOfTitle + height, _position.w, fontHeight, _entry.fileType.c_str(), ALIGN_LEFT);
|
if (_entry.state != FileState::ILOCAL)
|
||||||
|
DrawTextRect(_position.x, _position.y + heightOfTitle + height, _position.w, fontHeight, _entry.fileType.c_str(), ALIGN_LEFT);
|
||||||
|
|
||||||
switch(_entry.state)
|
switch(_entry.state)
|
||||||
{
|
{
|
||||||
case FileState::ISYNCED:
|
case FileState::ISYNCED:
|
||||||
text = "Synced";
|
text = "Downloaded";
|
||||||
break;
|
break;
|
||||||
case FileState::IOUTSYNCED:
|
case FileState::IOUTSYNCED:
|
||||||
text = "Out of sync";
|
text = "Out of sync";
|
||||||
break;
|
break;
|
||||||
|
case FileState::ILOCAL:
|
||||||
|
text = "Local";
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
text = "Click to download";
|
text = "Click to download";
|
||||||
}
|
}
|
||||||
|
@ -65,15 +64,19 @@ void WebDAVViewEntry::draw(const ifont *entryFont, const ifont *entryFontBold, i
|
||||||
case FileState::IOUTSYNCED:
|
case FileState::IOUTSYNCED:
|
||||||
text = "Structure of out sync";
|
text = "Structure of out sync";
|
||||||
break;
|
break;
|
||||||
|
case FileState::IDOWNLOADED:
|
||||||
|
text = "Downloaded";
|
||||||
|
break;
|
||||||
case FileState::ICLOUD:
|
case FileState::ICLOUD:
|
||||||
text = "Cloud";
|
text = "Cloud";
|
||||||
break;
|
break;
|
||||||
default:
|
case FileState::ILOCAL:
|
||||||
text = {};
|
text = "Local";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DrawTextRect(_position.x, _position.y + heightOfTitle + fontHeight + height, _position.w, fontHeight, text.c_str(), ALIGN_RIGHT);
|
DrawTextRect(_position.x, _position.y + heightOfTitle + fontHeight + height, _position.w, fontHeight, text.c_str(), ALIGN_RIGHT);
|
||||||
DrawTextRect(_position.x, _position.y + heightOfTitle + fontHeight + height, _position.w, fontHeight, _entry.size.c_str(), ALIGN_LEFT);
|
if (_entry.state != FileState::ILOCAL)
|
||||||
|
DrawTextRect(_position.x, _position.y + heightOfTitle + fontHeight + height, _position.w, fontHeight, _entry.size.c_str(), ALIGN_LEFT);
|
||||||
|
|
||||||
time_t now;
|
time_t now;
|
||||||
time(&now);
|
time(&now);
|
||||||
|
|
Loading…
Reference in New Issue