hotfix: multithread loading

This commit is contained in:
semenov
2025-08-07 16:47:15 +03:00
parent 28ea4338e0
commit d58835d9d6
12 changed files with 338 additions and 312 deletions

View File

@@ -19,7 +19,7 @@ void SendSystem::initialize(DataParser *dataParser,QMutex *globalMutex)
void SendSystem::setClient(Client *client,QTcpSocket *socket)
{
this->socket = socket;
this->type = client->GETTYPE();
this->type = client->getClientType();
this->client = client;
isSendStopped = false;
}
@@ -86,8 +86,8 @@ void SendSystem::sendFileBlock(QString path)
void SendSystem::sendFileBlockByteArray(QByteArray array, PacketType packetType)
{
qDebug() << "sendFileBlockByteArray thread: " << QThread::currentThreadId();
if(client->GETTYPE() == TypeClientAutorization::TYPE_QT_CLIENT ||
client->GETTYPE() == TypeClientAutorization::TYPE_GUI)
if(client->getClientType() == TypeClientAutorization::TYPE_QT_CLIENT ||
client->getClientType() == TypeClientAutorization::TYPE_GUI)
{
QDataStream stream(socket);
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
@@ -179,7 +179,6 @@ void SendSystem::sendFolderBlock(QString path)
stream << PacketType::TYPE_FOLDER;
stream << path;
socket->waitForReadyRead(100);
}
void SendSystem::sendDeleteBlock(QString path)
@@ -195,8 +194,8 @@ void SendSystem::sendDeleteBlock(QString path)
void SendSystem::sendPacketType(PacketType packetType)
{
if (client->GETTYPE() == TypeClientAutorization::TYPE_QT_CLIENT ||
client->GETTYPE() == TypeClientAutorization::TYPE_GUI)
if (client->getClientType() == TypeClientAutorization::TYPE_QT_CLIENT ||
client->getClientType() == TypeClientAutorization::TYPE_GUI)
{
QDataStream stream(socket);
@@ -228,8 +227,8 @@ void SendSystem::sendNotify(QString notify)
void SendSystem::sendXmlAnswer(QByteArray array, PacketType packetType)
{
qDebug() << "SendSystemThread: " << QThread::currentThreadId();
if (client->GETTYPE() == TypeClientAutorization::TYPE_QT_CLIENT ||
client->GETTYPE() == TypeClientAutorization::TYPE_GUI)
if (client->getClientType() == TypeClientAutorization::TYPE_QT_CLIENT ||
client->getClientType() == TypeClientAutorization::TYPE_GUI)
{
QDataStream stream(socket);
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
@@ -262,7 +261,7 @@ void SendSystem::sendNeedUpdate(bool flag,quint64 size,quint64 fileCount,quint64
void SendSystem::updateFiles(QList<FileData> fileSendList, QList<FileData> deleteList){
mutex->lock();
QMutexLocker locker(mutex);
QListIterator<FileData> clientIterator(deleteList);
while(clientIterator.hasNext())
@@ -272,7 +271,6 @@ void SendSystem::updateFiles(QList<FileData> fileSendList, QList<FileData> delet
sendDeleteBlock(data.path);
if(getIsSendStopped())
{
mutex->unlock();
return;
}
}
@@ -296,16 +294,11 @@ void SendSystem::updateFiles(QList<FileData> fileSendList, QList<FileData> delet
if(isSendStopped)
{
mutex->unlock();
return;
}
}
emit sigLoadHash();
sendPacketType(PacketType::TYPE_FINISH);
socket->waitForBytesWritten();
mutex->unlock();
}
void SendSystem::socketWrite(QByteArray array)