This commit is contained in:
2026-02-24 11:17:48 +03:00
parent a1f3e04fad
commit a0e54c0e18
8 changed files with 79 additions and 44 deletions

View File

@@ -652,7 +652,7 @@ void ProcessingSystem::processingClientQueryTasksXML(ClientHandler *client, Clie
nameFile = tasksFIMfileName; nameFile = tasksFIMfileName;
pathFile = updateController->getPathAdditionalFile(nameFile); pathFile = updateController->getPathAdditionalFile(nameFile);
Logger::instance().log(pathFile); Logger::instance().log(pathFile);
client->sendFileBlock(pathFile); client->sendFileBlock_forGUI(pathFile);
client->sendPacketType(PacketType::TYPE_XMLANSWER_QUERY_TASKS_XML_FIM); client->sendPacketType(PacketType::TYPE_XMLANSWER_QUERY_TASKS_XML_FIM);
} }
else if(clientQueryTasksXML.Type == "amm") else if(clientQueryTasksXML.Type == "amm")
@@ -660,7 +660,7 @@ void ProcessingSystem::processingClientQueryTasksXML(ClientHandler *client, Clie
nameFile = tasksAMMfileName; nameFile = tasksAMMfileName;
pathFile = updateController->getPathAdditionalFile(nameFile); pathFile = updateController->getPathAdditionalFile(nameFile);
docsUpdater->lockAccessToDocsXML(); docsUpdater->lockAccessToDocsXML();
client->sendFileBlock(pathFile); client->sendFileBlock_forGUI(pathFile);
client->sendPacketType(PacketType::TYPE_XMLANSWER_QUERY_TASKS_XML_AMM); client->sendPacketType(PacketType::TYPE_XMLANSWER_QUERY_TASKS_XML_AMM);
docsUpdater->unLockAccessToDocsXML(); docsUpdater->unLockAccessToDocsXML();
} }

View File

@@ -31,7 +31,7 @@ void RecognizeSystem::initialize(UpdateController *updateController,DataParser*
connect(this,&RecognizeSystem::sigCopyVersion,updateController,&UpdateController::createCopyVersion,Qt::AutoConnection); connect(this,&RecognizeSystem::sigCopyVersion,updateController,&UpdateController::createCopyVersion,Qt::AutoConnection);
connect(this,&RecognizeSystem::sigXmlParser,dataParser->getProcessParser(),&ProcessParser::slot_read,Qt::AutoConnection); connect(this,&RecognizeSystem::sigXmlParser,dataParser->getProcessParser(),&ProcessParser::slot_read,Qt::AutoConnection);
//connect(this,&RecognizeSystem::sigRecalculateDocs,server,&ServerLMSWidget::slot_UpdateDocs,Qt::AutoConnection); //connect(this,&RecognizeSystem::sigRecalculateDocs,server,&ServerLMSWidget::slot_UpdateDocs,Qt::AutoConnection);
connect(this,&RecognizeSystem::sigSendDocs,sendSystem,&SendSystem::slot_sendDocs,Qt::AutoConnection); connect(this,&RecognizeSystem::sigSendDocs_forQtClient,sendSystem,&SendSystem::slot_sendDocs_forQtClient,Qt::AutoConnection);
} }
void RecognizeSystem::recognize() void RecognizeSystem::recognize()
@@ -454,8 +454,7 @@ void RecognizeSystem::recognize()
if(packetType == PacketType::GET_DOCS) if(packetType == PacketType::GET_DOCS)
{ {
emit sigSendDocs(updateController->getPathAdditionalFile(tasksAMMfileName)); emit sigSendDocs_forQtClient(updateController->getPathAdditionalFile(tasksAMMfileName));
//globalMutex->unlock();
} }
if (packetType == PacketType::SEND_HASH) if (packetType == PacketType::SEND_HASH)

View File

@@ -34,7 +34,7 @@ signals:
void sigDeleteVersion(QString versionName); void sigDeleteVersion(QString versionName);
void sigCopyVersion(QString versionName,QString newVersionName,QString author); void sigCopyVersion(QString versionName,QString newVersionName,QString author);
//void sigRecalculateDocs(); //void sigRecalculateDocs();
void sigSendDocs(QString docsPath); void sigSendDocs_forQtClient(QString docsPath);
void signal_updateDocsXML(); void signal_updateDocsXML();

View File

@@ -75,7 +75,7 @@ void SendSystem::updateFiles(QList<FileData> fileSendList, QList<FileData> delet
} }
else else
{ {
slot_sendFileBlock_V3(data.path); slot_sendFileBlock_forQtClient(data.path);
} }
if(slot_getIsSendingStopped()) if(slot_getIsSendingStopped())
@@ -184,9 +184,9 @@ void SendSystem::slot_sendXmlAnswer(QByteArray array, PacketType packetType)
} }
} }
void SendSystem::slot_sendDocs(QString docsPath) void SendSystem::slot_sendDocs_forQtClient(QString docsPath)
{ {
slot_sendFileBlock(docsPath); slot_sendFileBlock_forQtClient(docsPath);
} }
void SendSystem::slot_sendNeedUpdate(bool flag, quint64 size, quint64 fileCount, quint64 deleteCount) void SendSystem::slot_sendNeedUpdate(bool flag, quint64 size, quint64 fileCount, quint64 deleteCount)
@@ -224,7 +224,7 @@ void SendSystem::slot_sendDeleteBlock(QString path)
waitWrittenData("sendDeleteBlock"); waitWrittenData("sendDeleteBlock");
} }
void SendSystem::slot_sendFileBlock(QString path) void SendSystem::slot_sendFileBlock_forGUI(QString path)
{ {
//qDebug() << "SendSystem::sendFileBlock path: " << path; //qDebug() << "SendSystem::sendFileBlock path: " << path;
@@ -283,7 +283,7 @@ void SendSystem::slot_sendFileBlock(QString path)
countSend = 0; countSend = 0;
} }
void SendSystem::slot_sendFileBlock_V3(QString path) void SendSystem::slot_sendFileBlock_forQtClient(QString path)
{ {
//qDebug() << "SendSystem::sendFileBlock path: " << path; //qDebug() << "SendSystem::sendFileBlock path: " << path;
@@ -421,51 +421,85 @@ void SendSystem::slot_sendFileBlockByteArray(QByteArray array, PacketType packet
} }
} }
void SendSystem::slot_sendFileBlockWithRename(QString path, QString newName) void SendSystem::slot_sendFileBlockWithRename_Hash_forQtClient(QString path, QString newName)
{ {
//qDebug() << "SendSystem::sendFileBlockWithRename thread ID " << QThread::currentThreadId(); //qDebug() << "SendSystem::sendFileBlockWithRename thread ID " << QThread::currentThreadId();
QDataStream stream(socket); if(slot_getIsSendingStopped())
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion); { //Поведение на случай отключения клиента
Logger::instance().log("Client: " + client->getLogin() + " isSendingStopped", LogLevel::ERROR);
return;
}
QFile file(Tools::createRootPath(path)); QFile file(Tools::createRootPath(path));
QFileInfo fileInfo(file); QFileInfo fileInfo(file);
fileSize = fileInfo.size(); fileSize = fileInfo.size();
if(fileSize == 0){ if (fileSize == 0)
Logger::instance().log("Client: " + client->getLogin() + " WARNING! Zero size " + fileInfo.fileName(),LogLevel::ERROR); {
Logger::instance().log("Client: " + client->getLogin() + " ERROR! File zero size " + fileInfo.fileName(), LogLevel::ERROR);
Logger::instance().log(path, LogLevel::ERROR);
return;
}
if(!file.open(QFile::ReadOnly))
{
Logger::instance().log("Client: " + client->getLogin() + " ERROR! File not open: " + fileInfo.fileName(), LogLevel::ERROR);
Logger::instance().log(path, LogLevel::ERROR);
return; return;
} }
QString pathForSend = Tools::createFolderPath(path) + "/" + staticDataFolderName + newName; QString pathForSend = Tools::createFolderPath(path) + "/" + staticDataFolderName + newName;
countSend = 0;
QDataStream stream(socket);
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
stream << PacketType::TYPE_FILE; stream << PacketType::TYPE_FILE;
stream << pathForSend << fileSize; stream << pathForSend << fileSize;
waitWrittenData("sendFileBlockWithRename"); waitWrittenData("sendFileBlockWithRename");
if(slot_getIsSendingStopped()) { //Поведение на случай отключения клиента connect(this->socket, &QTcpSocket::bytesWritten, this, &SendSystem::slot_BytesWrittenToSocket);
file.close(); while(!file.atEnd())
return; {
} if(socket->state() == QAbstractSocket::UnconnectedState)
{
//socket->waitForBytesWritten(); Logger::instance().log("Client: " + client->getLogin() + " UnconnectedState", LogLevel::ERROR);
break;
if(file.open(QFile::ReadOnly)){
while(!file.atEnd()){
QByteArray data = file.read(sendFileBlockSize);
stream << data;
waitWrittenData("sendFileBlockWithRename");
countSend++;
} }
Logger::instance().log("Send file " + fileInfo.fileName()); qint64 readBytes = file.read(buffer, sendFileBlockSize);
if(readBytes <= 0)
break;
flWaitWritenToSocket = true;
while(!socket->write(buffer, readBytes))
{
qCritical() << "socket->write ERROR. size " + QString::number(readBytes);
int i = 0;
i++;
}
while(flWaitWritenToSocket)
{
QCoreApplication::processEvents(); // Обеспечиваем обработку сообщений
int i = 0;
i++;
}
waitWrittenData(QString("sendFileBlock:data (readBytes %1, num %2) ").arg(QString::number(readBytes), QString::number(countSend)) + fileInfo.fileName());
countSend++;
} }
disconnect(this->socket, &QTcpSocket::bytesWritten, this, &SendSystem::slot_BytesWrittenToSocket);
file.close(); file.close();
countSend = 0; countSend = 0;
waitWrittenData("sendFileBlockWithRename"); //waitWrittenData("sendFileBlockWithRename");
//socket->waitForReadyRead(100); //socket->waitForReadyRead(100);
slot_sendNotify(commandHashCompleteClient); slot_sendNotify(commandHashCompleteClient);

View File

@@ -43,17 +43,17 @@ public slots:
void slot_sendPacketType(PacketType packet); void slot_sendPacketType(PacketType packet);
void slot_sendXmlAnswer(QByteArray array, PacketType packetType = PacketType::TYPE_XMLANSWER); void slot_sendXmlAnswer(QByteArray array, PacketType packetType = PacketType::TYPE_XMLANSWER);
void slot_sendDocs(QString docPath); void slot_sendDocs_forQtClient(QString docPath);
void slot_sendNeedUpdate(bool flag,quint64 size,quint64 fileCount,quint64 deleteCount); void slot_sendNeedUpdate(bool flag,quint64 size,quint64 fileCount,quint64 deleteCount);
void slot_sendFolderBlock(QString path); void slot_sendFolderBlock(QString path);
void slot_sendDeleteBlock(QString path); void slot_sendDeleteBlock(QString path);
void slot_sendFileBlock(QString path); void slot_sendFileBlock_forGUI(QString path);
void slot_sendFileBlock_V3(QString path); void slot_sendFileBlock_forQtClient(QString path);
void slot_sendFileBlockByteArray(QByteArray array, PacketType packetType); void slot_sendFileBlockByteArray(QByteArray array, PacketType packetType);
void slot_sendFileBlockWithRename(QString path,QString newName); void slot_sendFileBlockWithRename_Hash_forQtClient(QString path,QString newName);
signals: signals:
QByteArray sigSendNotify(QString message); QByteArray sigSendNotify(QString message);

View File

@@ -54,10 +54,12 @@ void UpdateController::changeAssetVersion(QString versionName)
currentStreamingPath = assetManager->setVersion(versionName); currentStreamingPath = assetManager->setVersion(versionName);
setUpCurrentServerHash(); setUpCurrentServerHash();
emit sigUpdateDocsXML();
commonClientHandler->slot_sendPacketToAllClients(PacketType::HASH_READY, false); commonClientHandler->slot_sendPacketToAllClients(PacketType::HASH_READY, false);
commonClientHandler->sendCurrentVersionToAllClient(); commonClientHandler->sendCurrentVersionToAllClient();
emit sigUpdateDocsXML();
//commonClientHandler->slot_sendPacketToAllClients(PacketType::FREE); //commonClientHandler->slot_sendPacketToAllClients(PacketType::FREE);
res = emit signal_BlockAutorization(false, "SERVER", "ChangeAssetVersion"); res = emit signal_BlockAutorization(false, "SERVER", "ChangeAssetVersion");
} }

View File

@@ -44,14 +44,14 @@ void ClientHandler::initialize(int descriptor,
connect(this,&ClientHandler::sigSendXmlAnswer,sendSystem,&SendSystem::slot_sendXmlAnswer,Qt::AutoConnection); connect(this,&ClientHandler::sigSendXmlAnswer,sendSystem,&SendSystem::slot_sendXmlAnswer,Qt::AutoConnection);
//connect(this,&ClientHandler::sigInitSender,sendSystem,&SendSystem::initialize,Qt::AutoConnection/*Qt::DirectConnection*/); //connect(this,&ClientHandler::sigInitSender,sendSystem,&SendSystem::initialize,Qt::AutoConnection/*Qt::DirectConnection*/);
connect(this,&ClientHandler::sigFileBlock,sendSystem,&SendSystem::slot_sendFileBlock,Qt::AutoConnection); connect(this,&ClientHandler::sigFileBlock_forGUI,sendSystem,&SendSystem::slot_sendFileBlock_forGUI,Qt::AutoConnection);
connect(this,&ClientHandler::sigFileBlockByteArray,sendSystem,&SendSystem::slot_sendFileBlockByteArray,Qt::AutoConnection); connect(this,&ClientHandler::sigFileBlockByteArray,sendSystem,&SendSystem::slot_sendFileBlockByteArray,Qt::AutoConnection);
connect(this,&ClientHandler::sigFolderBlock,sendSystem,&SendSystem::slot_sendFolderBlock,Qt::AutoConnection); connect(this,&ClientHandler::sigFolderBlock,sendSystem,&SendSystem::slot_sendFolderBlock,Qt::AutoConnection);
connect(this,&ClientHandler::sigGetIsSendStopped,sendSystem,&SendSystem::slot_getIsSendingStopped,/*Qt::AutoConnection*/Qt::DirectConnection); //Возвращает значение connect(this,&ClientHandler::sigGetIsSendStopped,sendSystem,&SendSystem::slot_getIsSendingStopped,/*Qt::AutoConnection*/Qt::DirectConnection); //Возвращает значение
connect(this,&ClientHandler::sigSendDeleteBlock,sendSystem,&SendSystem::slot_sendDeleteBlock,Qt::AutoConnection); connect(this,&ClientHandler::sigSendDeleteBlock,sendSystem,&SendSystem::slot_sendDeleteBlock,Qt::AutoConnection);
connect(this,&ClientHandler::sigNeedUpdate,sendSystem,&SendSystem::slot_sendNeedUpdate,Qt::AutoConnection); connect(this,&ClientHandler::sigNeedUpdate,sendSystem,&SendSystem::slot_sendNeedUpdate,Qt::AutoConnection);
connect(this,&ClientHandler::sigSendNotify,sendSystem,&SendSystem::slot_sendNotify,Qt::AutoConnection); connect(this,&ClientHandler::sigSendNotify,sendSystem,&SendSystem::slot_sendNotify,Qt::AutoConnection);
connect(this,&ClientHandler::sigSendFileBlockWithRename,sendSystem,&SendSystem::slot_sendFileBlockWithRename,Qt::AutoConnection); connect(this,&ClientHandler::sigSendFileBlockWithRename_Hash_forQtClient,sendSystem,&SendSystem::slot_sendFileBlockWithRename_Hash_forQtClient,Qt::AutoConnection);
connect(this,&ClientHandler::sigSendVersion,sendSystem,&SendSystem::slot_sendVersion,Qt::AutoConnection); connect(this,&ClientHandler::sigSendVersion,sendSystem,&SendSystem::slot_sendVersion,Qt::AutoConnection);
connect(this,&ClientHandler::sigSocketClose,sendSystem,&SendSystem::slot_socketClose,Qt::AutoConnection); connect(this,&ClientHandler::sigSocketClose,sendSystem,&SendSystem::slot_socketClose,Qt::AutoConnection);
//connect(this,&ClientHandler::sigSocketFlush,sendSystem,&SendSystem::socketFlush,Qt::AutoConnection); //не используется //connect(this,&ClientHandler::sigSocketFlush,sendSystem,&SendSystem::socketFlush,Qt::AutoConnection); //не используется
@@ -101,7 +101,7 @@ void ClientHandler::initClientType()
void ClientHandler::sendHash() void ClientHandler::sendHash()
{ {
QString path = "\\" + hashFileName; QString path = "\\" + hashFileName;
emit sigSendFileBlockWithRename(path,"/serverHash.xml"); emit sigSendFileBlockWithRename_Hash_forQtClient(path,"/serverHash.xml");
//emit sigSendNotify("HASHSENDCOMPLETE"); //emit sigSendNotify("HASHSENDCOMPLETE");
} }
@@ -135,9 +135,9 @@ void ClientHandler::sendXmlAnswer(QByteArray array, PacketType packetType)
emit sigSendXmlAnswer(array, packetType); emit sigSendXmlAnswer(array, packetType);
} }
void ClientHandler::sendFileBlock(QString path) void ClientHandler::sendFileBlock_forGUI(QString path)
{ {
emit sigFileBlock(path); emit sigFileBlock_forGUI(path);
} }
void ClientHandler::sendFileBlockByteArray(QByteArray array, PacketType packetType) void ClientHandler::sendFileBlockByteArray(QByteArray array, PacketType packetType)

View File

@@ -27,7 +27,7 @@ public:
void initSender(DataParser *dataParser); void initSender(DataParser *dataParser);
void sendXmlAnswer(QByteArray array, PacketType packetType = PacketType::TYPE_XMLANSWER); void sendXmlAnswer(QByteArray array, PacketType packetType = PacketType::TYPE_XMLANSWER);
void sendFolderBlock(QString path); void sendFolderBlock(QString path);
void sendFileBlock(QString path); void sendFileBlock_forGUI(QString path);
void sendFileBlockByteArray(QByteArray array, PacketType packetType); void sendFileBlockByteArray(QByteArray array, PacketType packetType);
bool getIsSendStopped(); bool getIsSendStopped();
void sendDeleteBlock(QString path); void sendDeleteBlock(QString path);
@@ -53,7 +53,7 @@ signals:
void sigSendXmlAnswer(QByteArray array, PacketType packetType); void sigSendXmlAnswer(QByteArray array, PacketType packetType);
//void sigInitSender (DataParser *dataParse, QMutex *mutex); //void sigInitSender (DataParser *dataParse, QMutex *mutex);
void sigFolderBlock(QString path); void sigFolderBlock(QString path);
void sigFileBlock(QString path); void sigFileBlock_forGUI(QString path);
void sigFileBlockByteArray(QByteArray array, PacketType packetType); void sigFileBlockByteArray(QByteArray array, PacketType packetType);
bool sigGetIsSendStopped(); bool sigGetIsSendStopped();
void sigSendDeleteBlock(QString path); void sigSendDeleteBlock(QString path);
@@ -62,7 +62,7 @@ signals:
void sigSendHash(); void sigSendHash();
void sigRecognize(ClientHandler *handler); void sigRecognize(ClientHandler *handler);
void sigSendNotify(QString notify); void sigSendNotify(QString notify);
void sigSendFileBlockWithRename (QString path,QString newName); void sigSendFileBlockWithRename_Hash_forQtClient (QString path,QString newName);
void sigSocketClose(); void sigSocketClose();
//bool sigSocketFlush(); //не используется //bool sigSocketFlush(); //не используется
void sigSendVersion(); void sigSendVersion();