From 5959f2e7a0fad8c30b47c0f5aac04981ee2763e7 Mon Sep 17 00:00:00 2001 From: JuanJakobo Date: Fri, 29 Jul 2022 17:27:43 +0200 Subject: [PATCH] Fix #24 Enhance tests if file is still aviable --- src/api/sqliteConnector.cpp | 8 ++++++++ src/handler/eventHandler.cpp | 11 ++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/api/sqliteConnector.cpp b/src/api/sqliteConnector.cpp index deabb43..7305a7f 100644 --- a/src/api/sqliteConnector.cpp +++ b/src/api/sqliteConnector.cpp @@ -137,6 +137,14 @@ std::vector SqliteConnector::getItemsChildren(const string &parentPa temp.type = static_cast(sqlite3_column_int(stmt,7)); temp.state = static_cast(sqlite3_column_int(stmt,8)); + if(iv_access(temp.localPath.c_str(), W_OK) != 0) + { + if(temp.type == Itemtype::IFILE) + temp.state = FileState::ICLOUD; + else + iv_mkdir(temp.localPath.c_str(), 0777); + } + items.push_back(temp); } diff --git a/src/handler/eventHandler.cpp b/src/handler/eventHandler.cpp index 0f69a2d..7e2cdf2 100644 --- a/src/handler/eventHandler.cpp +++ b/src/handler/eventHandler.cpp @@ -554,9 +554,14 @@ void EventHandler::updateItems(vector &items) { item.state = _sqllite.getState(item.path); - //TODO integrate for files - //if (iv_access(temp.localPath.c_str(), W_OK) != 0) - //temp.state = FileState::ICLOUD; + if(iv_access(item.localPath.c_str(), W_OK) != 0) + { + if(item.type == Itemtype::IFILE) + item.state = FileState::ICLOUD; + else + iv_mkdir(item.localPath.c_str(), 0777); + } + if(_sqllite.getEtag(item.path).compare(item.etag) != 0) { if( item.state == FileState::ISYNCED)