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;
pathFile = updateController->getPathAdditionalFile(nameFile);
Logger::instance().log(pathFile);
client->sendFileBlock(pathFile);
client->sendFileBlock_forGUI(pathFile);
client->sendPacketType(PacketType::TYPE_XMLANSWER_QUERY_TASKS_XML_FIM);
}
else if(clientQueryTasksXML.Type == "amm")
@@ -660,7 +660,7 @@ void ProcessingSystem::processingClientQueryTasksXML(ClientHandler *client, Clie
nameFile = tasksAMMfileName;
pathFile = updateController->getPathAdditionalFile(nameFile);
docsUpdater->lockAccessToDocsXML();
client->sendFileBlock(pathFile);
client->sendFileBlock_forGUI(pathFile);
client->sendPacketType(PacketType::TYPE_XMLANSWER_QUERY_TASKS_XML_AMM);
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::sigXmlParser,dataParser->getProcessParser(),&ProcessParser::slot_read,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()
@@ -454,8 +454,7 @@ void RecognizeSystem::recognize()
if(packetType == PacketType::GET_DOCS)
{
emit sigSendDocs(updateController->getPathAdditionalFile(tasksAMMfileName));
//globalMutex->unlock();
emit sigSendDocs_forQtClient(updateController->getPathAdditionalFile(tasksAMMfileName));
}
if (packetType == PacketType::SEND_HASH)

View File

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

View File

@@ -75,7 +75,7 @@ void SendSystem::updateFiles(QList<FileData> fileSendList, QList<FileData> delet
}
else
{
slot_sendFileBlock_V3(data.path);
slot_sendFileBlock_forQtClient(data.path);
}
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)
@@ -224,7 +224,7 @@ void SendSystem::slot_sendDeleteBlock(QString path)
waitWrittenData("sendDeleteBlock");
}
void SendSystem::slot_sendFileBlock(QString path)
void SendSystem::slot_sendFileBlock_forGUI(QString path)
{
//qDebug() << "SendSystem::sendFileBlock path: " << path;
@@ -283,7 +283,7 @@ void SendSystem::slot_sendFileBlock(QString path)
countSend = 0;
}
void SendSystem::slot_sendFileBlock_V3(QString path)
void SendSystem::slot_sendFileBlock_forQtClient(QString 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();
QDataStream stream(socket);
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
if(slot_getIsSendingStopped())
{ //Поведение на случай отключения клиента
Logger::instance().log("Client: " + client->getLogin() + " isSendingStopped", LogLevel::ERROR);
return;
}
QFile file(Tools::createRootPath(path));
QFileInfo fileInfo(file);
fileSize = fileInfo.size();
if(fileSize == 0){
Logger::instance().log("Client: " + client->getLogin() + " WARNING! Zero size " + fileInfo.fileName(),LogLevel::ERROR);
if (fileSize == 0)
{
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;
}
QString pathForSend = Tools::createFolderPath(path) + "/" + staticDataFolderName + newName;
countSend = 0;
QDataStream stream(socket);
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
stream << PacketType::TYPE_FILE;
stream << pathForSend << fileSize;
waitWrittenData("sendFileBlockWithRename");
if(slot_getIsSendingStopped()) { //Поведение на случай отключения клиента
connect(this->socket, &QTcpSocket::bytesWritten, this, &SendSystem::slot_BytesWrittenToSocket);
file.close();
return;
while(!file.atEnd())
{
if(socket->state() == QAbstractSocket::UnconnectedState)
{
Logger::instance().log("Client: " + client->getLogin() + " UnconnectedState", LogLevel::ERROR);
break;
}
//socket->waitForBytesWritten();
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());
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());
}
disconnect(this->socket, &QTcpSocket::bytesWritten, this, &SendSystem::slot_BytesWrittenToSocket);
file.close();
countSend = 0;
waitWrittenData("sendFileBlockWithRename");
//waitWrittenData("sendFileBlockWithRename");
//socket->waitForReadyRead(100);
slot_sendNotify(commandHashCompleteClient);

View File

@@ -43,17 +43,17 @@ public slots:
void slot_sendPacketType(PacketType packet);
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_sendFolderBlock(QString path);
void slot_sendDeleteBlock(QString path);
void slot_sendFileBlock(QString path);
void slot_sendFileBlock_V3(QString path);
void slot_sendFileBlock_forGUI(QString path);
void slot_sendFileBlock_forQtClient(QString path);
void slot_sendFileBlockByteArray(QByteArray array, PacketType packetType);
void slot_sendFileBlockWithRename(QString path,QString newName);
void slot_sendFileBlockWithRename_Hash_forQtClient(QString path,QString newName);
signals:
QByteArray sigSendNotify(QString message);

View File

@@ -54,10 +54,12 @@ void UpdateController::changeAssetVersion(QString versionName)
currentStreamingPath = assetManager->setVersion(versionName);
setUpCurrentServerHash();
emit sigUpdateDocsXML();
commonClientHandler->slot_sendPacketToAllClients(PacketType::HASH_READY, false);
commonClientHandler->sendCurrentVersionToAllClient();
emit sigUpdateDocsXML();
//commonClientHandler->slot_sendPacketToAllClients(PacketType::FREE);
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::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::sigFolderBlock,sendSystem,&SendSystem::slot_sendFolderBlock,Qt::AutoConnection);
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::sigNeedUpdate,sendSystem,&SendSystem::slot_sendNeedUpdate,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::sigSocketClose,sendSystem,&SendSystem::slot_socketClose,Qt::AutoConnection);
//connect(this,&ClientHandler::sigSocketFlush,sendSystem,&SendSystem::socketFlush,Qt::AutoConnection); //не используется
@@ -101,7 +101,7 @@ void ClientHandler::initClientType()
void ClientHandler::sendHash()
{
QString path = "\\" + hashFileName;
emit sigSendFileBlockWithRename(path,"/serverHash.xml");
emit sigSendFileBlockWithRename_Hash_forQtClient(path,"/serverHash.xml");
//emit sigSendNotify("HASHSENDCOMPLETE");
}
@@ -135,9 +135,9 @@ void ClientHandler::sendXmlAnswer(QByteArray array, PacketType 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)

View File

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