mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJClient.git
synced 2026-03-28 05:25:39 +03:00
ref: hashComparer
This commit is contained in:
@@ -8,6 +8,7 @@ UpdateController::UpdateController(DataParser *parser,SendSystem *sendSystem, QO
|
||||
this->dataParser = parser;
|
||||
this->sendSystem = sendSystem;
|
||||
localPath = QDir::currentPath() + applicationFolderName;
|
||||
calculateStreamingHash();
|
||||
}
|
||||
|
||||
void UpdateController::calculateCommonHash()
|
||||
@@ -69,12 +70,13 @@ void UpdateController::calculateHash(QString path)
|
||||
readSize = qMin(fileSize,bufferSize);
|
||||
}
|
||||
|
||||
file.close();
|
||||
|
||||
|
||||
hashString = QString(hash.result().toHex());
|
||||
currentFile.path = Tools::createLocalPath(fileInfo.absoluteFilePath());
|
||||
currentFile.hash = hashString;
|
||||
files->push_back(currentFile);
|
||||
file.close();
|
||||
}
|
||||
else if (fileInfo.isDir() && !fileInfo.isRoot() && fileInfo.fileName() != "..")
|
||||
{
|
||||
|
||||
@@ -13,6 +13,7 @@ void HashComparer::CompareDeltas()
|
||||
{
|
||||
QList<FileData> *serverStreamingHash = new QList<FileData>;
|
||||
QList<FileData> *localStreamingHash = new QList<FileData>;
|
||||
QList<FileData> *files = new QList<FileData>;
|
||||
|
||||
QFile file(serverHash);
|
||||
file.open(QIODevice::ReadOnly | QIODevice::Text);
|
||||
@@ -30,14 +31,13 @@ void HashComparer::CompareDeltas()
|
||||
|
||||
for (auto &item:*localStreamingHash)
|
||||
{
|
||||
if(serverStreamingHash->contains(item))
|
||||
if(!serverStreamingHash->contains(item))
|
||||
{
|
||||
serverStreamingHash->removeOne(item);
|
||||
localStreamingHash->removeOne(item);
|
||||
files->append(item);
|
||||
}
|
||||
}
|
||||
|
||||
filesForUpdate = localStreamingHash;
|
||||
filesForUpdate = files;
|
||||
showDeltas();
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ RecognizeSystem::RecognizeSystem(QObject *parent):
|
||||
sizeReceiveData = 0;
|
||||
tmpBlock.clear();
|
||||
countSend = 0;
|
||||
folderList = new QList<QString>;
|
||||
}
|
||||
|
||||
RecognizeSystem::~RecognizeSystem()
|
||||
@@ -82,7 +83,6 @@ void RecognizeSystem::recognize(QTcpSocket *socket)
|
||||
|
||||
if(packetType == PacketType::TYPE_FILE) //загрузка файлов
|
||||
{
|
||||
|
||||
//ПОЛУЧЕНИЕ ПУТИ
|
||||
//ПОЛУЧЕНИЕ РАЗМЕРА ФАЙЛА
|
||||
forever
|
||||
@@ -107,7 +107,7 @@ void RecognizeSystem::recognize(QTcpSocket *socket)
|
||||
emit sigSendDebugLog("CLIENT: filesize: " + QString::number(fileSize));
|
||||
emit sigSendDebugLog("CLIENT: filePath: " + filePath);
|
||||
|
||||
emit sigSocketWaitForReadyRead(100);
|
||||
socket->waitForReadyRead(100);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -122,6 +122,7 @@ void RecognizeSystem::recognize(QTcpSocket *socket)
|
||||
{
|
||||
file.remove(); //удаление файла, если он уже есть, но необходимо обновить
|
||||
emit sigSendDebugLog(Tools::getTime() + "Delete exist file: " + filePath);
|
||||
socket->waitForReadyRead(100);
|
||||
}
|
||||
|
||||
|
||||
@@ -191,7 +192,8 @@ void RecognizeSystem::recognize(QTcpSocket *socket)
|
||||
|
||||
if(fileInfo.exists())
|
||||
{
|
||||
if(fileInfo.isFile()){
|
||||
if(fileInfo.isFile())
|
||||
{
|
||||
QFile file(filePath);
|
||||
file.remove();
|
||||
}
|
||||
@@ -226,6 +228,10 @@ void RecognizeSystem::recognize(QTcpSocket *socket)
|
||||
stream >> size;
|
||||
stream >> fileCount;
|
||||
|
||||
if(!stream.commitTransaction()){
|
||||
continue;
|
||||
}
|
||||
|
||||
emit sigNeedUpdate(flag,size,fileCount);
|
||||
packetType = PacketType::TYPE_NONE;
|
||||
}
|
||||
@@ -326,7 +332,6 @@ void RecognizeSystem::checkAccessType(QString type)
|
||||
{
|
||||
if(type == "instructor")
|
||||
{
|
||||
updateController->calculateStreamingHash();
|
||||
mainWindow->callUpdateList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ signals:
|
||||
void sigStartCompare();
|
||||
|
||||
private:
|
||||
QList<QString> *folderList;
|
||||
MainWindow *mainWindow;
|
||||
UpdateController *updateController;
|
||||
DataParser *dataParser;
|
||||
|
||||
@@ -96,7 +96,7 @@ void TCPClient::slotSendCommand(QString command)
|
||||
emit sigSendDebugLog("Update started");
|
||||
stream << PacketType::TYPE_COMMAND;
|
||||
stream << command;
|
||||
socket->waitForBytesWritten();
|
||||
socket->waitForReadyRead(1000);
|
||||
}
|
||||
else if(command == "run"){
|
||||
externalExecuter->callApp();
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <QTime>
|
||||
#include <QDebug>
|
||||
|
||||
#define TCP_READ_TIMEOUT 1000
|
||||
#define TCP_READ_TIMEOUT 2000
|
||||
|
||||
static QString applicationEXEName = "RRJ.exe";
|
||||
static QString applicationFolderName = "/Application";
|
||||
|
||||
Reference in New Issue
Block a user