ref: segregate client hashes

This commit is contained in:
semenov
2025-11-20 12:14:50 +03:00
parent 560b7ff4cb
commit bd0bed926c
7 changed files with 78 additions and 19 deletions

View File

@@ -36,7 +36,7 @@ void RecognizeSystem::initialize(UpdateController *updateController,DataParser*
void RecognizeSystem::recognize()
{
QMutexLocker locker(mutex);
QMutexLocker locker(mutex);
qDebug() << "Recognize thread ID " << QThread::currentThreadId();
QDataStream stream(socket);
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
@@ -118,10 +118,7 @@ void RecognizeSystem::recognize()
if(packetType == PacketType::TYPE_CHECK_VERSION)
{
QFile checkFile(clientHash);
checkFile.open(QIODevice::ReadOnly);
updateController->compareFiles(clientHandler,checkFile.readAll());
checkFile.close();
updateController->compareFiles(clientHandler,client->getClientHash());
}
if (packetType == PacketType::TYPE_XMLANSWER)
@@ -454,11 +451,60 @@ void RecognizeSystem::recognize()
emit sigSendDocs(updateController->getPathAdditionalFile(tasksAMMfileName));
}
// if(packetType == PacketType::RECALCULATE_HASH)
// {
// emit sigCalculateHash();
// }
if (packetType == PacketType::SEND_HASH)
{
QByteArray hash;
forever
{
stream.startTransaction();
stream >> fileSize;
if(!stream.commitTransaction()) continue;
socket->waitForReadyRead(100);
break;
}
forever
{
stream.startTransaction();
stream >> tmpBlock;
if(!stream.commitTransaction()){
if(socket->state() == QAbstractSocket::UnconnectedState){
qDebug() << "UNCONNECT";
//mutex->unlock();
return;
}
if(socket->waitForReadyRead(100)){
continue;
}
continue;
}
hash += tmpBlock;
sizeReceiveData += tmpBlock.length();
countSend++;
tmpBlock.clear();
if(sizeReceiveData == fileSize) break;
}
QString logMessage = "Load from " + client->getLogin() + " ";
filePath.clear();
fileSize = 0;
tmpBlock.clear();
sizeReceiveData = 0;
countSend = 0;
packetType = PacketType::TYPE_NONE;
client->setClientHash(hash);
}
packetType = PacketType::TYPE_NONE;
}