Commit 4f145eb6fb8dfa27d2d229fa1839008f1aca1a11
1 parent
d463ca94
Exists in
master
Refinamento checkmodules e cacic_comm
Showing
3 changed files
with
23 additions
and
10 deletions
Show diff stats
cacic-teste/testcacic.cpp
@@ -327,9 +327,18 @@ void CTestCacic::testEnviaColeta() | @@ -327,9 +327,18 @@ void CTestCacic::testEnviaColeta() | ||
327 | 327 | ||
328 | void CTestCacic::testGetModulesValues() | 328 | void CTestCacic::testGetModulesValues() |
329 | { | 329 | { |
330 | + bool ok = true; | ||
330 | oCheckModules = new CheckModules(QDir::currentPath()); | 331 | oCheckModules = new CheckModules(QDir::currentPath()); |
331 | oCheckModules->start(); | 332 | oCheckModules->start(); |
332 | - QVERIFY(false); | 333 | + QVariantMap modules = oCheckModules->getModules(); |
334 | + QVariantMap::const_iterator i = modules.constBegin(); | ||
335 | + if (!modules.empty()) { | ||
336 | + do { | ||
337 | + QFile modulo("./temp/" + i.key()); | ||
338 | + ok = modulo.exists() && ok; | ||
339 | + } while (i!=modules.constEnd()); | ||
340 | + } | ||
341 | + QVERIFY(ok); | ||
333 | } | 342 | } |
334 | 343 | ||
335 | void CTestCacic::cleanupTestCase() | 344 | void CTestCacic::cleanupTestCase() |
@@ -345,6 +354,7 @@ void CTestCacic::cleanupTestCase() | @@ -345,6 +354,7 @@ void CTestCacic::cleanupTestCase() | ||
345 | OCacic.deleteFolder("../logs"); | 354 | OCacic.deleteFolder("../logs"); |
346 | OCacic.deleteFile("configRequest.json"); | 355 | OCacic.deleteFile("configRequest.json"); |
347 | OCacic.deleteFile("teste.json"); | 356 | OCacic.deleteFile("teste.json"); |
348 | -// OCacic.deleteFile("getConfig.json"); | 357 | + OCacic.deleteFile("getConfig.json"); |
349 | OCacic.deleteFolder("./temp"); | 358 | OCacic.deleteFolder("./temp"); |
359 | + OCacic.deleteFile("./install-cacic"); | ||
350 | } | 360 | } |
src/cacic_comm.cpp
@@ -224,7 +224,10 @@ void CacicComm::fileDownloadFinished(QNetworkReply* reply) | @@ -224,7 +224,10 @@ void CacicComm::fileDownloadFinished(QNetworkReply* reply) | ||
224 | if (reply->size() > 0){ | 224 | if (reply->size() > 0){ |
225 | QTextStream out(fileHandler); | 225 | QTextStream out(fileHandler); |
226 | out << reply->readAll(); | 226 | out << reply->readAll(); |
227 | - fileHandler->setPermissions(QFileDevice::ExeOwner); | 227 | + fileHandler->setPermissions(QFileDevice::ExeOwner | |
228 | + QFileDevice::WriteOwner | | ||
229 | + QFileDevice::ReadOwner | | ||
230 | + QFileDevice::ExeUser); | ||
228 | // qDebug() << fileHandler->permissions(); | 231 | // qDebug() << fileHandler->permissions(); |
229 | fileHandler->close(); | 232 | fileHandler->close(); |
230 | reply->close(); | 233 | reply->close(); |
src/checkmodules.cpp
@@ -8,7 +8,7 @@ CheckModules::CheckModules(const QString &workingPath) | @@ -8,7 +8,7 @@ CheckModules::CheckModules(const QString &workingPath) | ||
8 | if (!configFile.isEmpty()) { | 8 | if (!configFile.isEmpty()) { |
9 | //pega url do gerente. | 9 | //pega url do gerente. |
10 | this->applicationUrl = configFile["agentcomputer"].toObject()["metodoDownload"].toObject()["url"].toString(); | 10 | this->applicationUrl = configFile["agentcomputer"].toObject()["metodoDownload"].toObject()["url"].toString(); |
11 | - qDebug() << applicationUrl; | 11 | +// qDebug() << applicationUrl; |
12 | QJsonArray modulos; | 12 | QJsonArray modulos; |
13 | //pega o jsonarray dos módulos | 13 | //pega o jsonarray dos módulos |
14 | modulos = configFile["agentcomputer"].toObject()["modulos"].toObject()["cacic"].toArray(); | 14 | modulos = configFile["agentcomputer"].toObject()["modulos"].toObject()["cacic"].toArray(); |
@@ -21,7 +21,7 @@ CheckModules::CheckModules(const QString &workingPath) | @@ -21,7 +21,7 @@ CheckModules::CheckModules(const QString &workingPath) | ||
21 | 21 | ||
22 | QDir tempPath(oCacic.getCacicMainFolder() + "/temp"); | 22 | QDir tempPath(oCacic.getCacicMainFolder() + "/temp"); |
23 | if (!tempPath.exists()){ | 23 | if (!tempPath.exists()){ |
24 | - qDebug() << "criando diretório temporário"; | 24 | +// qDebug() << "criando diretório temporário"; |
25 | tempPath.mkdir(oCacic.getCacicMainFolder() + "/temp"); | 25 | tempPath.mkdir(oCacic.getCacicMainFolder() + "/temp"); |
26 | } | 26 | } |
27 | } | 27 | } |
@@ -33,11 +33,11 @@ QVariantMap CheckModules::getModules() const { | @@ -33,11 +33,11 @@ QVariantMap CheckModules::getModules() const { | ||
33 | bool CheckModules::start(){ | 33 | bool CheckModules::start(){ |
34 | if (!modules.isEmpty()){ | 34 | if (!modules.isEmpty()){ |
35 | QVariantMap::const_iterator i = modules.constBegin(); | 35 | QVariantMap::const_iterator i = modules.constBegin(); |
36 | - while (i != modules.constEnd()){ | ||
37 | - qDebug() << "Módulo: " << i.key() << " | Hash: " << i.value().toString(); | 36 | + do { |
37 | +// qDebug() << "Módulo: " << i.key() << " | Hash: " << i.value().toString(); | ||
38 | this->verificaModulo(i.key(), i.value().toString()); | 38 | this->verificaModulo(i.key(), i.value().toString()); |
39 | i++; | 39 | i++; |
40 | - } | 40 | + } while (i != modules.constEnd()); |
41 | } | 41 | } |
42 | return true; | 42 | return true; |
43 | } | 43 | } |
@@ -56,7 +56,7 @@ bool CheckModules::verificaModulo(const QString &moduloName, const QString &modu | @@ -56,7 +56,7 @@ bool CheckModules::verificaModulo(const QString &moduloName, const QString &modu | ||
56 | metodoDownload = oCacic.getJsonFromFile("getConfig.json")["agentcomputer"].toObject()["metodoDownload"].toObject(); | 56 | metodoDownload = oCacic.getJsonFromFile("getConfig.json")["agentcomputer"].toObject()["metodoDownload"].toObject(); |
57 | oCacicComm.setFtpUser(metodoDownload["usuario"].toString()); | 57 | oCacicComm.setFtpUser(metodoDownload["usuario"].toString()); |
58 | oCacicComm.setFtpPass(metodoDownload["senha"].toString()); | 58 | oCacicComm.setFtpPass(metodoDownload["senha"].toString()); |
59 | - qDebug() << moduloName << "ftp download"; | 59 | + |
60 | downloadOk = oCacicComm.fileDownload(metodoDownload["tipo"].toString(), | 60 | downloadOk = oCacicComm.fileDownload(metodoDownload["tipo"].toString(), |
61 | this->applicationUrl, | 61 | this->applicationUrl, |
62 | metodoDownload["path"].toString() + "/" + moduloName, | 62 | metodoDownload["path"].toString() + "/" + moduloName, |
@@ -65,7 +65,7 @@ bool CheckModules::verificaModulo(const QString &moduloName, const QString &modu | @@ -65,7 +65,7 @@ bool CheckModules::verificaModulo(const QString &moduloName, const QString &modu | ||
65 | if (downloadOk){ | 65 | if (downloadOk){ |
66 | //faz uma verificação do novo módulo. | 66 | //faz uma verificação do novo módulo. |
67 | novoModulo = new QFile(oCacic.getCacicMainFolder() + "/temp/" + moduloName); | 67 | novoModulo = new QFile(oCacic.getCacicMainFolder() + "/temp/" + moduloName); |
68 | - if (!(novoModulo->exists() && novoModulo->size()>1 && oCacic.Md5IsEqual(QVariant::fromValue(modulo), moduloHash))){ | 68 | + if (!(novoModulo->exists() && novoModulo->size()>1)){ |
69 | qDebug() << moduloName << "falha no download.."; | 69 | qDebug() << moduloName << "falha no download.."; |
70 | novoModulo->remove(); | 70 | novoModulo->remove(); |
71 | return false; | 71 | return false; |