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 | 327 | |
328 | 328 | void CTestCacic::testGetModulesValues() |
329 | 329 | { |
330 | + bool ok = true; | |
330 | 331 | oCheckModules = new CheckModules(QDir::currentPath()); |
331 | 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 | 344 | void CTestCacic::cleanupTestCase() |
... | ... | @@ -345,6 +354,7 @@ void CTestCacic::cleanupTestCase() |
345 | 354 | OCacic.deleteFolder("../logs"); |
346 | 355 | OCacic.deleteFile("configRequest.json"); |
347 | 356 | OCacic.deleteFile("teste.json"); |
348 | -// OCacic.deleteFile("getConfig.json"); | |
357 | + OCacic.deleteFile("getConfig.json"); | |
349 | 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 | 224 | if (reply->size() > 0){ |
225 | 225 | QTextStream out(fileHandler); |
226 | 226 | out << reply->readAll(); |
227 | - fileHandler->setPermissions(QFileDevice::ExeOwner); | |
227 | + fileHandler->setPermissions(QFileDevice::ExeOwner | | |
228 | + QFileDevice::WriteOwner | | |
229 | + QFileDevice::ReadOwner | | |
230 | + QFileDevice::ExeUser); | |
228 | 231 | // qDebug() << fileHandler->permissions(); |
229 | 232 | fileHandler->close(); |
230 | 233 | reply->close(); | ... | ... |
src/checkmodules.cpp
... | ... | @@ -8,7 +8,7 @@ CheckModules::CheckModules(const QString &workingPath) |
8 | 8 | if (!configFile.isEmpty()) { |
9 | 9 | //pega url do gerente. |
10 | 10 | this->applicationUrl = configFile["agentcomputer"].toObject()["metodoDownload"].toObject()["url"].toString(); |
11 | - qDebug() << applicationUrl; | |
11 | +// qDebug() << applicationUrl; | |
12 | 12 | QJsonArray modulos; |
13 | 13 | //pega o jsonarray dos módulos |
14 | 14 | modulos = configFile["agentcomputer"].toObject()["modulos"].toObject()["cacic"].toArray(); |
... | ... | @@ -21,7 +21,7 @@ CheckModules::CheckModules(const QString &workingPath) |
21 | 21 | |
22 | 22 | QDir tempPath(oCacic.getCacicMainFolder() + "/temp"); |
23 | 23 | if (!tempPath.exists()){ |
24 | - qDebug() << "criando diretório temporário"; | |
24 | +// qDebug() << "criando diretório temporário"; | |
25 | 25 | tempPath.mkdir(oCacic.getCacicMainFolder() + "/temp"); |
26 | 26 | } |
27 | 27 | } |
... | ... | @@ -33,11 +33,11 @@ QVariantMap CheckModules::getModules() const { |
33 | 33 | bool CheckModules::start(){ |
34 | 34 | if (!modules.isEmpty()){ |
35 | 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 | 38 | this->verificaModulo(i.key(), i.value().toString()); |
39 | 39 | i++; |
40 | - } | |
40 | + } while (i != modules.constEnd()); | |
41 | 41 | } |
42 | 42 | return true; |
43 | 43 | } |
... | ... | @@ -56,7 +56,7 @@ bool CheckModules::verificaModulo(const QString &moduloName, const QString &modu |
56 | 56 | metodoDownload = oCacic.getJsonFromFile("getConfig.json")["agentcomputer"].toObject()["metodoDownload"].toObject(); |
57 | 57 | oCacicComm.setFtpUser(metodoDownload["usuario"].toString()); |
58 | 58 | oCacicComm.setFtpPass(metodoDownload["senha"].toString()); |
59 | - qDebug() << moduloName << "ftp download"; | |
59 | + | |
60 | 60 | downloadOk = oCacicComm.fileDownload(metodoDownload["tipo"].toString(), |
61 | 61 | this->applicationUrl, |
62 | 62 | metodoDownload["path"].toString() + "/" + moduloName, |
... | ... | @@ -65,7 +65,7 @@ bool CheckModules::verificaModulo(const QString &moduloName, const QString &modu |
65 | 65 | if (downloadOk){ |
66 | 66 | //faz uma verificação do novo módulo. |
67 | 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 | 69 | qDebug() << moduloName << "falha no download.."; |
70 | 70 | novoModulo->remove(); |
71 | 71 | return false; | ... | ... |