From adbd8395cac3b98dc776f874462aac9f7390e542 Mon Sep 17 00:00:00 2001 From: semenov Date: Wed, 15 Jan 2025 16:13:55 +0300 Subject: [PATCH 1/5] hotfix: updateController --- ServerLMS/Systems/recognizesystem.cpp | 20 ++-- ServerLMS/Systems/tools.h | 1 + ServerLMS/Systems/updatecontroller.cpp | 144 +++++++++++++++++-------- ServerLMS/Systems/updatecontroller.h | 2 - 4 files changed, 109 insertions(+), 58 deletions(-) diff --git a/ServerLMS/Systems/recognizesystem.cpp b/ServerLMS/Systems/recognizesystem.cpp index 8e30805..2389ca6 100644 --- a/ServerLMS/Systems/recognizesystem.cpp +++ b/ServerLMS/Systems/recognizesystem.cpp @@ -90,13 +90,23 @@ void RecognizeSystem::recognize() if (command == commandUpdateFilesClient) //запускает процесс оновления { sendSystem->updateFiles(updateController->getFileSendList(), - updateController->getClientDataList()); + updateController->getFileDeleteList()); qDebug()<< "Call update"; packetType = PacketType::TYPE_NONE; command = ""; } + if(command == "check") + { + command = ""; + QFile checkFile(clientHash); + checkFile.open(QIODevice::ReadOnly); + updateController->compareFiles(clientHandler,checkFile.readAll()); + checkFile.close(); + + } + if (packetType == PacketType::TYPE_XMLANSWER) { @@ -280,14 +290,6 @@ void RecognizeSystem::recognize() file.close(); - if(command == "check") - { - QFile checkFile(filePath); - checkFile.open(QIODevice::ReadOnly); - updateController->compareFiles(clientHandler,checkFile.readAll()); - checkFile.close(); - } - filePath.clear(); fileSize = 0; tmpBlock.clear(); diff --git a/ServerLMS/Systems/tools.h b/ServerLMS/Systems/tools.h index f78fff9..e896664 100644 --- a/ServerLMS/Systems/tools.h +++ b/ServerLMS/Systems/tools.h @@ -22,6 +22,7 @@ static const QString versionListFile = staticDataFolderName + "/versionList.xml" static const QString hashFileName = staticDataFolderName + "/serverHash.xml"; static const QString buildHashName = staticDataFolderName + "/buildHash.xml"; static const QString buildDataPath = "/Application/RRJLoader/RRJ_Data/"; +static const QString clientHash = staticDataFolderName + "/clientHash.xml"; static const QString baseNameVersion = "base";//может вынести комманды куда нибудь? diff --git a/ServerLMS/Systems/updatecontroller.cpp b/ServerLMS/Systems/updatecontroller.cpp index 7a548c1..088337f 100644 --- a/ServerLMS/Systems/updatecontroller.cpp +++ b/ServerLMS/Systems/updatecontroller.cpp @@ -59,7 +59,6 @@ void UpdateController::compareFiles(ClientHandler* handler, QByteArray array) loadHash(); clientDataList.clear(); xmlFileDataParse(array); - clientDataList.append(*datas); checkNeedUpdate(handler); mutex->unlock(); } @@ -182,8 +181,6 @@ QString UpdateController::getCommands() } - - void UpdateController::setUpCurrentServerHash() { QList *fileList = new QList; @@ -296,62 +293,121 @@ QList* UpdateController::calculateHash(QString path) { serverDataList.clear(); - QDirIterator iterator(path,QDirIterator::Subdirectories); if(!QDir(path).exists()){ QDir().mkdir(path); } - QDir dir(path); - dir.setFilter(QDir::NoDotAndDotDot); QString hashString; + QStringList filter; + filter << "*"; QList *files = new QList; - while (iterator.hasNext()) + QDirIterator dirIterator(path,filter, QDir::AllEntries | QDir::NoDotAndDotDot, QDirIterator::Subdirectories); + + while (dirIterator.hasNext()) { - iterator.next(); - QFileInfo fileInfo = iterator.fileInfo(); + QFileInfo fileInfo(dirIterator.next()); FileData currentFile; - QFile file(fileInfo.absoluteFilePath()); - - quint64 fileSize = file.size(); - const quint64 bufferSize = 10240; - - if (fileInfo.isHidden()) continue; - - if(fileInfo.isFile() && file.open(QIODevice::ReadOnly) && !fileInfo.fileName().contains(".meta")) + if(fileInfo.isDir() && !fileInfo.fileName().startsWith(".") && fileInfo.fileName() != "RRJLoader") { - char buffer[bufferSize]; - int bytesRead; - int readSize = qMin(fileSize,bufferSize); - - QCryptographicHash hash(QCryptographicHash::Md5); - while(readSize > 0 && (bytesRead = file.read(buffer,readSize)) > 0){ - fileSize -= bytesRead; - hash.addData(buffer,bytesRead); - readSize = qMin(fileSize,bufferSize); - } - - hashString = QString(hash.result().toHex()); - currentFile.hash = hashString; currentFile.path = Tools::createLocalPath(fileInfo.absoluteFilePath()); - - files->push_back(currentFile); - file.close(); - - } - else if(fileInfo.isDir() && fileInfo.fileName() != ".." && !fileInfo.isRoot()) - { currentFile.hash = "FOLDER"; - currentFile.path = Tools::createLocalPath(fileInfo.path()); - if(!files->contains(currentFile)){ + if(!files->contains(currentFile)) + { files->push_back(currentFile); } } } - std::sort(files->begin(),files->end()); + QDirIterator fileIterator(path,filter,QDir::Files | QDir::NoDotAndDotDot,QDirIterator::Subdirectories); + + while (fileIterator.hasNext()) + { + fileIterator.next(); + QFileInfo fileInfo = fileIterator.fileInfo(); + FileData currentFile; + QFile file(fileInfo.absoluteFilePath()); + + quint64 fileSize = file.size(); //буффер для хэширования крупных файлов + const quint64 bufferSize = 10240; + + if(fileInfo.isHidden()) continue; + + if(fileInfo.isFile() && file.open(QIODevice::ReadOnly) && !fileInfo.fileName().contains(".meta")) + { + char buffer[bufferSize]; + int bytesRead; + int readSize = qMin(fileSize,bufferSize); + + QCryptographicHash hash(QCryptographicHash::Md5); + + while(readSize > 0 && (bytesRead = file.read(buffer,readSize)) > 0) + { + fileSize -= bytesRead; + hash.addData(buffer,bytesRead); + readSize = qMin(fileSize,bufferSize); + } + + hashString = QString(hash.result().toHex()); + currentFile.path = Tools::createLocalPath(fileInfo.absoluteFilePath()); + currentFile.hash = hashString; + files->push_back(currentFile); + file.close(); + } + } serverDataList.append(*files); + +// QDirIterator iterator(path,QDirIterator::Subdirectories); +// QDir dir(path); +// dir.setFilter(QDir::NoDotAndDotDot); + +// while (iterator.hasNext()) +// { +// iterator.next(); +// QFileInfo fileInfo = iterator.fileInfo(); +// FileData currentFile; +// QFile file(fileInfo.absoluteFilePath()); + +// quint64 fileSize = file.size(); +// const quint64 bufferSize = 10240; + +// if (fileInfo.isHidden()) continue; + +// if(fileInfo.isFile() && file.open(QIODevice::ReadOnly) && !fileInfo.fileName().contains(".meta")) +// { +// char buffer[bufferSize]; +// int bytesRead; +// int readSize = qMin(fileSize,bufferSize); + +// QCryptographicHash hash(QCryptographicHash::Md5); +// while(readSize > 0 && (bytesRead = file.read(buffer,readSize)) > 0){ +// fileSize -= bytesRead; +// hash.addData(buffer,bytesRead); +// readSize = qMin(fileSize,bufferSize); +// } + +// hashString = QString(hash.result().toHex()); +// currentFile.hash = hashString; +// currentFile.path = Tools::createLocalPath(fileInfo.absoluteFilePath()); + +// files->push_back(currentFile); +// file.close(); + +// } +// else if(fileInfo.isDir() && fileInfo.fileName() != ".." && !fileInfo.isRoot()) +// { +// currentFile.hash = "FOLDER"; +// currentFile.path = Tools::createLocalPath(fileInfo.path()); + +// if(!files->contains(currentFile)){ +// files->push_back(currentFile); +// } +// } +// } + +// std::sort(files->begin(),files->end()); +// return files; } @@ -499,7 +555,6 @@ bool UpdateController::checkDuplicate(QString versionName) void UpdateController::xmlFileDataParse(QByteArray array) { QXmlStreamReader xmlReader(array); - datas = new QList; xmlReader.readNext(); //Крутимся в цикле до тех пор, пока не достигнем конца документа @@ -523,7 +578,7 @@ void UpdateController::xmlFileDataParse(QByteArray array) data.hash = value; } - datas->append(data); + clientDataList.append(data); } } @@ -565,11 +620,6 @@ DataInfo *UpdateController::getCurrentDataInfo() return dataInfo; } -QList *UpdateController::getDatas() const -{ - return datas; -} - void UpdateController::clearCurrentDataInfo() { delete dataInfo; diff --git a/ServerLMS/Systems/updatecontroller.h b/ServerLMS/Systems/updatecontroller.h index 611ef2f..efe3aee 100644 --- a/ServerLMS/Systems/updatecontroller.h +++ b/ServerLMS/Systems/updatecontroller.h @@ -51,7 +51,6 @@ public: DataInfo *getCurrentDataInfo(); void clearCurrentDataInfo(); - QList *getDatas() const; void createVersionListXmlAnswer(QList version); void saveVersionToFile(StreamingVersionData *streamingVersion); void xmlFileDataParse(QByteArray array); @@ -71,7 +70,6 @@ private: QList fileSendList; QList fileDeleteList; - QList *datas; DataInfo *dataInfo; QString buildPath; From e7b13f4ec436e96c3dc9fd40b7573078495d032c Mon Sep 17 00:00:00 2001 From: semenov Date: Thu, 16 Jan 2025 11:12:46 +0300 Subject: [PATCH 2/5] bugfix: loading process disable --- DOCS/Алексей/Board.md | 11 ++++- ServerLMS/Systems/commonclienthandler.cpp | 9 ++-- ServerLMS/Systems/commonclienthandler.h | 2 +- ServerLMS/Systems/sendsystem.cpp | 37 +++++++++------- ServerLMS/Systems/updatecontroller.cpp | 51 ----------------------- ServerLMS/clienthandler.cpp | 7 +++- ServerLMS/clienthandler.h | 1 + ServerLMS/multithreadserver.cpp | 9 ++-- ServerLMS/multithreadserver.h | 1 + ServerLMS/serverlmswidget.cpp | 10 +++-- 10 files changed, 54 insertions(+), 84 deletions(-) diff --git a/DOCS/Алексей/Board.md b/DOCS/Алексей/Board.md index 102b856..2be5125 100644 --- a/DOCS/Алексей/Board.md +++ b/DOCS/Алексей/Board.md @@ -12,6 +12,11 @@ kanban-plugin: board ## bugs +- [ ] QT сервер замерзает после выхода пользователя во время скачивания +- [ ] QT клиент, если обновление в режиме инструктора доступно, кнопку запуск отключать +- [ ] QT сервер При изменении версии правильный списке с файлами прилетает со второго раза +- [ ] QT сервер Найти причину двойного вызова проверки при логине инструктором +- [ ] QT клиент: device not open после прерывания загрузки ## feature client Unity @@ -30,9 +35,8 @@ kanban-plugin: board ## feature server -- [ ] Прибраться в Server -- [ ] рефакторинг - [ ] добавить генерацию пустых файлов, если shared не найден +- [ ] добавить подключение без DB ## NOW @@ -42,6 +46,9 @@ kanban-plugin: board ## Complete +- [ ] рефакторинг +- [ ] Прибраться в Server +- [ ] не работает восстановление файлов - [ ] запрет на удаление base - [ ] None hash - [ ] сверстать окно создания новой версии diff --git a/ServerLMS/Systems/commonclienthandler.cpp b/ServerLMS/Systems/commonclienthandler.cpp index 6012e3e..e7e769d 100644 --- a/ServerLMS/Systems/commonclienthandler.cpp +++ b/ServerLMS/Systems/commonclienthandler.cpp @@ -11,6 +11,8 @@ void CommonClientHandler::initialize(QMap *clientsMap, Pro this->processingSystem = processingSystem; this->dataParser = dataParser; this->logger = logger; + + connect(this,&CommonClientHandler::sigSendToLogger,logger,&Logger::addTextToLogger,Qt::AutoConnection); } void CommonClientHandler::sendNewVersionListToAllClient() @@ -85,7 +87,8 @@ void CommonClientHandler::slot_msgToClientFromGUI(QString login, QString text) QString str = "Msg To Client [" + peerAddress + ":" + peerPort + "] : " + textMsg; - logger->addTextToLogger(str); + emit sigSendToLogger(str); + break; } } @@ -111,7 +114,7 @@ void CommonClientHandler::slot_msgToGUIfromClient(QString login, QString text) QString str = "Msg From Client [" + peerAddress + ":" + peerPort + "] : " + textMsg; - logger->addTextToLogger(str); + emit sigSendToLogger(str); break; } } @@ -134,7 +137,7 @@ void CommonClientHandler::slot_sendTaskToClient(QString fullNameClient,QString t QString peerPort = QString::number(handler->getSocket()->peerPort()); QString str = "Task To Client [" + peerAddress + ":" + peerPort + "] : " + textTask; - logger->addTextToLogger(str); + emit sigSendToLogger(str); } } } diff --git a/ServerLMS/Systems/commonclienthandler.h b/ServerLMS/Systems/commonclienthandler.h index a6e471b..1abf5b8 100644 --- a/ServerLMS/Systems/commonclienthandler.h +++ b/ServerLMS/Systems/commonclienthandler.h @@ -27,7 +27,7 @@ public: void slot_msgToGUIfromClient(QString login, QString text); void slot_sendTaskToClient(QString fullNameClient, QString textTask); signals: - + void sigSendToLogger(QString text); private: QMap *clientsMap; ProcessingSystem *processingSystem; diff --git a/ServerLMS/Systems/sendsystem.cpp b/ServerLMS/Systems/sendsystem.cpp index 29b2324..65caacd 100644 --- a/ServerLMS/Systems/sendsystem.cpp +++ b/ServerLMS/Systems/sendsystem.cpp @@ -35,14 +35,22 @@ void SendSystem::sendMessageBlock(QString message) void SendSystem::sendFileBlock(QString path) { - qDebug() << "sendFileBlock thread: " << QThread::currentThreadId(); + QFile file(path); + QFileInfo fileInfo(file); + + if(isSendStopped) + { //Поведение на случай отключения клиента + + file.close(); + return; + } + QDataStream stream(socket); stream.setVersion(QDataStream::Qt_DefaultCompiledVersion); - QFile file(path); - QFileInfo fileInfo(file); + fileSize = fileInfo.size(); if(fileSize == 0){ @@ -55,20 +63,19 @@ void SendSystem::sendFileBlock(QString path) stream << path << fileSize; - if(isSendStopped) { //Поведение на случай отключения клиента - - file.close(); - return; - } - socket->waitForBytesWritten(); + socket->waitForBytesWritten(10); - if(file.open(QFile::ReadOnly)){ - while(!file.atEnd()){ + if(file.open(QFile::ReadOnly)) + { + while(!file.atEnd()) + { QByteArray data = file.read(1025*250); stream << data; - socket->waitForBytesWritten(); + socket->waitForBytesWritten(10); + + if(socket->state() == QAbstractSocket::UnconnectedState) break; countSend++; } @@ -77,7 +84,7 @@ void SendSystem::sendFileBlock(QString path) file.close(); countSend = 0; - socket->waitForBytesWritten(); + socket->waitForBytesWritten(10); socket->waitForReadyRead(100); } @@ -237,11 +244,9 @@ void SendSystem::updateFiles(QList fileSendList, QList delet socket->waitForReadyRead(100); } - if(getIsSendStopped()) return; + if(isSendStopped) return; } - - emit sigLoadHash(); sendPacketType(PacketType::TYPE_FINISH); diff --git a/ServerLMS/Systems/updatecontroller.cpp b/ServerLMS/Systems/updatecontroller.cpp index 088337f..f83fd53 100644 --- a/ServerLMS/Systems/updatecontroller.cpp +++ b/ServerLMS/Systems/updatecontroller.cpp @@ -357,57 +357,6 @@ QList* UpdateController::calculateHash(QString path) } } serverDataList.append(*files); - -// QDirIterator iterator(path,QDirIterator::Subdirectories); -// QDir dir(path); -// dir.setFilter(QDir::NoDotAndDotDot); - -// while (iterator.hasNext()) -// { -// iterator.next(); -// QFileInfo fileInfo = iterator.fileInfo(); -// FileData currentFile; -// QFile file(fileInfo.absoluteFilePath()); - -// quint64 fileSize = file.size(); -// const quint64 bufferSize = 10240; - -// if (fileInfo.isHidden()) continue; - -// if(fileInfo.isFile() && file.open(QIODevice::ReadOnly) && !fileInfo.fileName().contains(".meta")) -// { -// char buffer[bufferSize]; -// int bytesRead; -// int readSize = qMin(fileSize,bufferSize); - -// QCryptographicHash hash(QCryptographicHash::Md5); -// while(readSize > 0 && (bytesRead = file.read(buffer,readSize)) > 0){ -// fileSize -= bytesRead; -// hash.addData(buffer,bytesRead); -// readSize = qMin(fileSize,bufferSize); -// } - -// hashString = QString(hash.result().toHex()); -// currentFile.hash = hashString; -// currentFile.path = Tools::createLocalPath(fileInfo.absoluteFilePath()); - -// files->push_back(currentFile); -// file.close(); - -// } -// else if(fileInfo.isDir() && fileInfo.fileName() != ".." && !fileInfo.isRoot()) -// { -// currentFile.hash = "FOLDER"; -// currentFile.path = Tools::createLocalPath(fileInfo.path()); - -// if(!files->contains(currentFile)){ -// files->push_back(currentFile); -// } -// } -// } - -// std::sort(files->begin(),files->end()); -// return files; } diff --git a/ServerLMS/clienthandler.cpp b/ServerLMS/clienthandler.cpp index 2ab918e..30c8448 100644 --- a/ServerLMS/clienthandler.cpp +++ b/ServerLMS/clienthandler.cpp @@ -54,6 +54,7 @@ void ClientHandler::initialize(int descriptor,ServerLMSWidget *serverWidget, connect(this,&ClientHandler::sigSocketClose,sendSystem,&SendSystem::socketClose,Qt::AutoConnection); connect(this,&ClientHandler::sigSocketFlush,sendSystem,&SendSystem::socketFlush,Qt::AutoConnection); connect(this,&ClientHandler::sigSendPacketType,sendSystem,&SendSystem::sendPacketType,Qt::AutoConnection); + connect(this,&ClientHandler::sigSendStop,sendSystem,&SendSystem::sendStop,Qt::DirectConnection); connect(socket,&QTcpSocket::readyRead,recognizeSystem,&RecognizeSystem::recognize,Qt::AutoConnection); connect(socket, &QTcpSocket::disconnected, this, &ClientHandler::sendDisable,Qt::AutoConnection); @@ -129,8 +130,10 @@ void ClientHandler::sendNeedUpdate(bool flag, quint64 size, quint64 fileCount,qu void ClientHandler::sendDisable() { - thread->exit(); - thread->wait(); +// thread->exit(); +// thread->wait(); + thread->quit(); + emit sigSendStop(); emit sigClientDisconnected(client->getAddress(),client->getPort()); } diff --git a/ServerLMS/clienthandler.h b/ServerLMS/clienthandler.h index 7e035b8..7f840db 100644 --- a/ServerLMS/clienthandler.h +++ b/ServerLMS/clienthandler.h @@ -67,6 +67,7 @@ signals: bool sigSocketFlush(); void sigSendVersion(); void sigSendPacketType(PacketType packetType); + void sigSendStop(); public : QThread *thread; diff --git a/ServerLMS/multithreadserver.cpp b/ServerLMS/multithreadserver.cpp index 1ac463d..50a0217 100644 --- a/ServerLMS/multithreadserver.cpp +++ b/ServerLMS/multithreadserver.cpp @@ -8,7 +8,7 @@ MultiThreadServer::MultiThreadServer(ServerLMSWidget *widget,UpdateController *u dataParser(dataParser), logger(logger) { - + connect(this,&MultiThreadServer::sigSendToLogger,logger,&Logger::addTextToLogger); } void MultiThreadServer::incomingConnection(qintptr socketDesriptor) @@ -16,14 +16,14 @@ void MultiThreadServer::incomingConnection(qintptr socketDesriptor) ClientHandler* newClient = new ClientHandler; connect(this,&MultiThreadServer::sigInitClient,newClient,&ClientHandler::initialize,Qt::AutoConnection); - connect(newClient,&ClientHandler::sigClientDisconnected,this,&MultiThreadServer::slotDisconnectClient,Qt::QueuedConnection); + connect(newClient,&ClientHandler::sigClientDisconnected,this,&MultiThreadServer::slotDisconnectClient,Qt::AutoConnection); emit sigInitClient(socketDesriptor,serverLmsWidget,updateController,dataParser,logger); disconnect(this,&MultiThreadServer::sigInitClient,newClient,&ClientHandler::initialize); serverLmsWidget->addClient(socketDesriptor,newClient); - logger->addTextToLogger("To Client: " + QString(SERVER_HELLO)); + emit sigSendToLogger("To Client: " + QString(SERVER_HELLO)); } void MultiThreadServer::slotDisconnectClient(QString peerAddress, QString peerPort) @@ -53,8 +53,7 @@ void MultiThreadServer::slotDisconnectClient(QString peerAddress, QString peerPo } emit signalStopSendFile(); - - logger->addTextToLogger("SERVER: Client " + login + " disconnected"); + emit sigSendToLogger("SERVER: Client " + login + " disconnected"); serverLmsWidget->slotUpdateListClients(); serverLmsWidget->autorizationHandler(login); diff --git a/ServerLMS/multithreadserver.h b/ServerLMS/multithreadserver.h index 13a4c50..eb12f80 100644 --- a/ServerLMS/multithreadserver.h +++ b/ServerLMS/multithreadserver.h @@ -18,6 +18,7 @@ signals: void sigInitClient(int descriptor, ServerLMSWidget *serverWidget, UpdateController *updateController, DataParser *dataParser,Logger *logger); void signalStopSendFile(); + void sigSendToLogger(QString text); public slots: void slotDisconnectClient(QString peerAddress, QString peerPort); diff --git a/ServerLMS/serverlmswidget.cpp b/ServerLMS/serverlmswidget.cpp index f52eb00..b90a0c3 100644 --- a/ServerLMS/serverlmswidget.cpp +++ b/ServerLMS/serverlmswidget.cpp @@ -14,7 +14,7 @@ ServerLMSWidget::ServerLMSWidget(QWidget *parent) : tcpServer(nullptr), hostPort(6000), stateServer(stoped), - stateBlockAutorization(blocked), + stateBlockAutorization(unblocked), updateThread(nullptr), loggerThread(nullptr), dataParser(nullptr), @@ -44,11 +44,13 @@ ServerLMSWidget::ServerLMSWidget(QWidget *parent) : loggerThread = new QThread; providerDBLMS = new ProviderDBLMS(this); - connect(providerDBLMS, &ProviderDBLMS::signal_BlockAutorization, this, &ServerLMSWidget::slot_BlockAutorization); providerDBLMS->ConnectionToDB(); logger = new Logger(ui->listWidgetLogger); - connect(logger,&Logger::sigSendTextToLogger,this,&ServerLMSWidget::slotAddToLog,Qt::QueuedConnection); + + connect(providerDBLMS, &ProviderDBLMS::signal_BlockAutorization, this, &ServerLMSWidget::slot_BlockAutorization); + connect(logger,&Logger::sigSendTextToLogger,this,&ServerLMSWidget::slotAddToLog,Qt::AutoConnection); + logger->moveToThread(loggerThread); assetsManager = new AssetsManager; @@ -194,7 +196,7 @@ void ServerLMSWidget::slotUpdateListClients() } int countClients = clientsMap.count(); - logger->addTextToLogger("SERVER: countClients = " + QString::number(countClients)); + emit sigLog("SERVER: countClients = " + QString::number(countClients)); } void ServerLMSWidget::slot_BlockAutorization(bool block) From 13c83e29908043484eef180c738bd19b62760b0e Mon Sep 17 00:00:00 2001 From: semenov Date: Thu, 16 Jan 2025 13:26:28 +0300 Subject: [PATCH 3/5] bugfix: create sharedData folder --- DOCS/Алексей/Board.md | 16 +++++++++------- DOCS/Алексей/ТЕСТ-КЕЙСЫ.md | 12 +++++++++++- ServerLMS/Systems/updatecontroller.cpp | 8 ++++++++ 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/DOCS/Алексей/Board.md b/DOCS/Алексей/Board.md index 2be5125..b0760b5 100644 --- a/DOCS/Алексей/Board.md +++ b/DOCS/Алексей/Board.md @@ -6,17 +6,11 @@ kanban-plugin: board ## backLog -- [ ] выписать все варианты взаимодействия между всеми клиентами и сервером -- [ ] sendSystem::sendXmlAnswer новый вариант отпарвки XML пакетов ## bugs -- [ ] QT сервер замерзает после выхода пользователя во время скачивания -- [ ] QT клиент, если обновление в режиме инструктора доступно, кнопку запуск отключать -- [ ] QT сервер При изменении версии правильный списке с файлами прилетает со второго раза - [ ] QT сервер Найти причину двойного вызова проверки при логине инструктором -- [ ] QT клиент: device not open после прерывания загрузки ## feature client Unity @@ -37,15 +31,19 @@ kanban-plugin: board - [ ] добавить генерацию пустых файлов, если shared не найден - [ ] добавить подключение без DB +- [ ] ПЕРЕВЕСТИ все действия под операции и формировать процент из них ## NOW -- [ ] добавить автоматическое выключение после создания копии ## Complete +- [ ] добавить автоматическое выключение после создания копии +- [ ] sendSystem::sendXmlAnswer новый вариант отпарвки XML пакетов +- [ ] выписать все варианты взаимодействия между всеми клиентами и сервером +- [ ] QT клиента: Не показывает блокировка, если версия удаляется - [ ] рефакторинг - [ ] Прибраться в Server - [ ] не работает восстановление файлов @@ -272,6 +270,10 @@ kanban-plugin: board ## BUGFIX Complete +- [ ] QT клиент: device not open после прерывания загрузки +- [ ] QT сервер При изменении версии правильный списке с файлами прилетает со второго раза +- [ ] QT клиент, если обновление в режиме инструктора доступно, кнопку запуск отключать +- [ ] QT сервер замерзает после выхода пользователя во время скачивания - [ ] Клиент QT выводить инфу если клиент не подключен - [ ] Клиент QT не подключатся повторно, если соединение уже установлено - [ ] Клиент QT Неправильное отображение количества загруженных файлов diff --git a/DOCS/Алексей/ТЕСТ-КЕЙСЫ.md b/DOCS/Алексей/ТЕСТ-КЕЙСЫ.md index 2443d6c..e0bf81b 100644 --- a/DOCS/Алексей/ТЕСТ-КЕЙСЫ.md +++ b/DOCS/Алексей/ТЕСТ-КЕЙСЫ.md @@ -29,4 +29,14 @@ 5. Обновление с клиента на сервер - ЕСТЬ 6. Проверка с перезапуском клиента - ХЭШ КОРРЕКТНЫЙ 7. Восстановление версии с сервера на клиент -8. Проверка с перезапуском клиента \ No newline at end of file +8. Проверка с перезапуском клиента + +Работа с версиями +1. QT клиент: Копирование версии +2. QT клиент: Копирование версии с указанием существующего имени -> ошибка +3. QT клиент: Удаление версии +4. QT клиент: Удаление базовой версии -> ошибка +5. QT клиент: Удаление версии которая выбрана -> ошибка +6. QT клиент: переключении версии +7. Unity: отправка в базовую версию +8. \ No newline at end of file diff --git a/ServerLMS/Systems/updatecontroller.cpp b/ServerLMS/Systems/updatecontroller.cpp index f83fd53..7b0247a 100644 --- a/ServerLMS/Systems/updatecontroller.cpp +++ b/ServerLMS/Systems/updatecontroller.cpp @@ -50,7 +50,9 @@ void UpdateController::createCopyVersion(QString versionName,QString newVersionN void UpdateController::deleteAssetVersion(QString versionName) { + commonClientHandler->slot_sendPacketToAllClients(PacketType::BUSY); assetManager->deleteVersion(versionName); + commonClientHandler->slot_sendPacketToAllClients(PacketType::FREE); } void UpdateController::compareFiles(ClientHandler* handler, QByteArray array) @@ -403,6 +405,12 @@ void UpdateController::CalculateSizeToSend(QList diffList) void UpdateController::calculateSharedHash() { QDir sharedDir(sharedDataPath); + + if(!QDir(sharedDataPath).exists()) + { + QDir().mkdir(sharedDataPath); + } + QDirIterator dirIterator(sharedDir); QList *fileList = new QList; QList *versionList = new QList; From 4b9ee1738ac6942733d309a078f22a02b80032bb Mon Sep 17 00:00:00 2001 From: semenov Date: Fri, 17 Jan 2025 11:10:34 +0300 Subject: [PATCH 4/5] bugfix: diff update --- DOCS/Алексей/Board.md | 6 ++++-- ServerLMS/Data/PacketType.h | 2 ++ ServerLMS/Data/StreamingVersionData.h | 14 ++++++++++++++ ServerLMS/Systems/recognizesystem.cpp | 8 +++----- ServerLMS/Systems/updatecontroller.cpp | 2 +- 5 files changed, 24 insertions(+), 8 deletions(-) diff --git a/DOCS/Алексей/Board.md b/DOCS/Алексей/Board.md index b0760b5..55eae26 100644 --- a/DOCS/Алексей/Board.md +++ b/DOCS/Алексей/Board.md @@ -10,7 +10,7 @@ kanban-plugin: board ## bugs -- [ ] QT сервер Найти причину двойного вызова проверки при логине инструктором +- [ ] При старт стопе не сканится шэред дата ## feature client Unity @@ -24,7 +24,6 @@ kanban-plugin: board - [ ] Иерархия проекта - папка application, папка updater и линк на основной экзешник - [ ] на старте все мониторы должны быть активны - [ ] Нужен ли дополнительный выбор для загрузки с мат моделью или нет? -- [ ] при создании копии переключение сервера и переключения клиента ## feature server @@ -32,6 +31,7 @@ kanban-plugin: board - [ ] добавить генерацию пустых файлов, если shared не найден - [ ] добавить подключение без DB - [ ] ПЕРЕВЕСТИ все действия под операции и формировать процент из них +- [ ] блокировать выгрузку под инструктором, если режим версия base ## NOW @@ -270,6 +270,8 @@ kanban-plugin: board ## BUGFIX Complete +- [ ] при создании копии переключение сервера и переключения клиента +- [ ] QT сервер Найти причину двойного вызова проверки при логине инструктором - [ ] QT клиент: device not open после прерывания загрузки - [ ] QT сервер При изменении версии правильный списке с файлами прилетает со второго раза - [ ] QT клиент, если обновление в режиме инструктора доступно, кнопку запуск отключать diff --git a/ServerLMS/Data/PacketType.h b/ServerLMS/Data/PacketType.h index 2b54672..326dda7 100644 --- a/ServerLMS/Data/PacketType.h +++ b/ServerLMS/Data/PacketType.h @@ -14,6 +14,8 @@ enum PacketType TYPE_XMLANSWER = 8, TYPE_QT = 9, TYPE_DISABLE = 11, + TYPE_UPDATE = 12, + TYPE_CHECK_VERSION = 13, TYPE_FILESIZE = 20, TYPE_XMLANSWER_MESSAGE_FOR_GUI = 90, diff --git a/ServerLMS/Data/StreamingVersionData.h b/ServerLMS/Data/StreamingVersionData.h index 3746bd7..007b368 100644 --- a/ServerLMS/Data/StreamingVersionData.h +++ b/ServerLMS/Data/StreamingVersionData.h @@ -36,11 +36,25 @@ public: return size; } + bool getIsChangeable() const; + void setIsChangeable(bool value); + private: QString absolutePath; QString viewName; QDateTime createData; + bool isChangeable; qint32 size; }; #endif // STREAMINGVERSIONDATA_H + +bool StreamingVersionData::getIsChangeable() const +{ +return isChangeable; +} + +void StreamingVersionData::setIsChangeable(bool value) +{ +isChangeable = value; +} diff --git a/ServerLMS/Systems/recognizesystem.cpp b/ServerLMS/Systems/recognizesystem.cpp index 2389ca6..46e929d 100644 --- a/ServerLMS/Systems/recognizesystem.cpp +++ b/ServerLMS/Systems/recognizesystem.cpp @@ -87,24 +87,22 @@ void RecognizeSystem::recognize() if (!stream.commitTransaction()) continue; } - if (command == commandUpdateFilesClient) //запускает процесс оновления + if (packetType == PacketType::TYPE_UPDATE) { + sendSystem->updateFiles(updateController->getFileSendList(), updateController->getFileDeleteList()); qDebug()<< "Call update"; packetType = PacketType::TYPE_NONE; - command = ""; } - if(command == "check") + if(packetType == PacketType::TYPE_CHECK_VERSION) { - command = ""; QFile checkFile(clientHash); checkFile.open(QIODevice::ReadOnly); updateController->compareFiles(clientHandler,checkFile.readAll()); checkFile.close(); - } if (packetType == PacketType::TYPE_XMLANSWER) diff --git a/ServerLMS/Systems/updatecontroller.cpp b/ServerLMS/Systems/updatecontroller.cpp index 7b0247a..08c7e9c 100644 --- a/ServerLMS/Systems/updatecontroller.cpp +++ b/ServerLMS/Systems/updatecontroller.cpp @@ -479,6 +479,7 @@ void UpdateController::createVersionListXmlAnswer(QList xmlWriter.writeEndDocument(); file.close(); } + void UpdateController::saveVersionToFile(StreamingVersionData *streamingVersion) //TODO: переименовать и перебросить в AssetManager { QFile file(version); @@ -498,7 +499,6 @@ void UpdateController::saveVersionToFile(StreamingVersionData *streamingVersion) file.close(); } - void UpdateController::sendNewVersionList() { commonClientHandler->sendNewVersionListToAllClient(); From 91a4b04f05a01883f4cce276554ca57b8837370c Mon Sep 17 00:00:00 2001 From: semenov Date: Fri, 17 Jan 2025 16:47:22 +0300 Subject: [PATCH 5/5] feat: load to server block --- DOCS/Алексей/Board.md | 3 ++ ServerLMS/Data/StreamingVersionData.h | 22 +++++++------- ServerLMS/Systems/Parsers/processparser.cpp | 3 ++ ServerLMS/Systems/processingsystem.cpp | 19 +++++++++++- ServerLMS/Systems/processingsystem.h | 9 ++++-- ServerLMS/Systems/recognizesystem.cpp | 33 +++++++++++++++++++++ ServerLMS/Systems/recognizesystem.h | 2 ++ ServerLMS/Systems/tools.h | 4 +++ ServerLMS/Systems/updatecontroller.cpp | 18 ++++++++++- ServerLMS/Systems/updatecontroller.h | 1 + ServerLMS/serverlmswidget.cpp | 2 +- 11 files changed, 99 insertions(+), 17 deletions(-) diff --git a/DOCS/Алексей/Board.md b/DOCS/Алексей/Board.md index 55eae26..5507615 100644 --- a/DOCS/Алексей/Board.md +++ b/DOCS/Алексей/Board.md @@ -6,6 +6,8 @@ kanban-plugin: board ## backLog +- [ ] окошко с выбором перенести в GUI +- [ ] Клиент НЕ СМОЖЕТ ВЫБИРАТЬ ВЕРСИИ ## bugs @@ -24,6 +26,7 @@ kanban-plugin: board - [ ] Иерархия проекта - папка application, папка updater и линк на основной экзешник - [ ] на старте все мониторы должны быть активны - [ ] Нужен ли дополнительный выбор для загрузки с мат моделью или нет? +- [ ] передавать полную версию в StreaminVerData ## feature server diff --git a/ServerLMS/Data/StreamingVersionData.h b/ServerLMS/Data/StreamingVersionData.h index 007b368..5cd2ffc 100644 --- a/ServerLMS/Data/StreamingVersionData.h +++ b/ServerLMS/Data/StreamingVersionData.h @@ -13,6 +13,7 @@ public: this->viewName = viewName; this->createData = data; this->size = size; + this->isChangeable = true; } ~StreamingVersionData(); @@ -36,8 +37,15 @@ public: return size; } - bool getIsChangeable() const; - void setIsChangeable(bool value); + bool getIsChangeable() const + { + return isChangeable; + } + + void setIsChangeable(bool value) + { + isChangeable = value; + } private: QString absolutePath; @@ -48,13 +56,3 @@ private: }; #endif // STREAMINGVERSIONDATA_H - -bool StreamingVersionData::getIsChangeable() const -{ -return isChangeable; -} - -void StreamingVersionData::setIsChangeable(bool value) -{ -isChangeable = value; -} diff --git a/ServerLMS/Systems/Parsers/processparser.cpp b/ServerLMS/Systems/Parsers/processparser.cpp index 7a94451..314d84a 100644 --- a/ServerLMS/Systems/Parsers/processparser.cpp +++ b/ServerLMS/Systems/Parsers/processparser.cpp @@ -239,6 +239,7 @@ void ProcessParser::clientMessage(QXmlStreamReader &xmlReader,ClientHandler *cli } processingSystem->processingFromClientMessage(client, clientMessage); + } void ProcessParser::clientNotify(QXmlStreamReader &xmlReader,ClientHandler *client) @@ -255,6 +256,8 @@ void ProcessParser::clientNotify(QXmlStreamReader &xmlReader,ClientHandler *clie clientNotify.Code = value; } + + processingSystem->processingClientNotify(client, clientNotify); } diff --git a/ServerLMS/Systems/processingsystem.cpp b/ServerLMS/Systems/processingsystem.cpp index ae055ab..87ee13c 100644 --- a/ServerLMS/Systems/processingsystem.cpp +++ b/ServerLMS/Systems/processingsystem.cpp @@ -8,11 +8,16 @@ ProcessingSystem::ProcessingSystem(ProviderDBLMS* providerDBLMS, QObject *parent this->providerDBLMS = providerDBLMS; } -void ProcessingSystem::initialize(ServerLMSWidget *server, DataParser *dataParser, CommonClientHandler *commonClientHandler,Logger *logger) +void ProcessingSystem::initialize(ServerLMSWidget *server, + DataParser *dataParser, + CommonClientHandler *commonClientHandler, + Logger *logger, + UpdateController *updateController) { this->commonClientServer = commonClientHandler; this->dataParser = dataParser; this->server = server; + this->updateController = updateController; connect(this,&ProcessingSystem::sigAuthChanged,commonClientHandler, &CommonClientHandler::slot_AuthChanged,Qt::AutoConnection); connect(this,&ProcessingSystem::sigUpdateListClients,server, &ServerLMSWidget::slotUpdateListClients,Qt::AutoConnection); @@ -278,6 +283,18 @@ void ProcessingSystem::processingClientNotify(ClientHandler *client, ClientNotif { client->sendVersionList(); } + else if(clientNotify.Code == commandCanChangeVersion) + { + if (updateController->getCurrentVersion()->getIsChangeable()) + { + client->sigSendNotify(commandChangable); + } + else + { + client->sigSendNotify(commandUnchangable); + } + + } } diff --git a/ServerLMS/Systems/processingsystem.h b/ServerLMS/Systems/processingsystem.h index 22dc00d..d5b82fb 100644 --- a/ServerLMS/Systems/processingsystem.h +++ b/ServerLMS/Systems/processingsystem.h @@ -23,7 +23,12 @@ class ProcessingSystem : public QObject public: explicit ProcessingSystem(ProviderDBLMS* providerDBLMS, QObject *parent = nullptr); - void initialize(ServerLMSWidget *server,DataParser* dataParser,CommonClientHandler *commonClientServer,Logger *logger); + void initialize(ServerLMSWidget *server, + DataParser* dataParser, + CommonClientHandler *commonClientServer, + Logger *logger, + UpdateController *updateComtroller); + void processingClientAutorization(ClientHandler *client, ClientAutorization clientAutorization); void processingClientDeAutorization(ClientHandler *client, ClientDeAutorization clientDeAutorization); void processingClientQueryToDB(ClientHandler *client, ClientQueryToDB clientQueryToDB, int id = 0, void* data = nullptr); @@ -44,7 +49,7 @@ private: CommonClientHandler *commonClientServer; ServerLMSWidget *server; DataParser *dataParser; - //InstructorsAndTraineesWidget *pInstructorsAndTrainees; + UpdateController *updateController; ProviderDBLMS* providerDBLMS; }; diff --git a/ServerLMS/Systems/recognizesystem.cpp b/ServerLMS/Systems/recognizesystem.cpp index 46e929d..be2e1d9 100644 --- a/ServerLMS/Systems/recognizesystem.cpp +++ b/ServerLMS/Systems/recognizesystem.cpp @@ -168,6 +168,16 @@ void RecognizeSystem::recognize() QFile file(filePath); +// //ПРОВЕРКА НА ИЗМЕНЕНИЕ БАЗОВОЙ ВЕРСИИ +// bool check = checkIsChangeable(); +// bool check2 = checkNonStaticData(filePath); +// if(!check && check2) +// { +// packetType = PacketType::TYPE_NONE; +// sendSystem->sendNotify(commandTryBaseChange); +// mutex->unlock(); +// return; +// } if (file.exists()) { @@ -239,6 +249,17 @@ void RecognizeSystem::recognize() break; } +// //ПРОВЕРКА НА ИЗМЕНЕНИЕ БАЗОВОЙ ВЕРСИИ +// bool check = checkIsChangeable(); +// bool check2 = checkNonStaticData(filePath); +// if(!check && check2) +// { +// sendSystem->sendNotify(commandTryBaseChange); +// packetType = PacketType::TYPE_NONE; +// mutex->unlock(); +// return; +// } + QFile file(filePath); QFileInfo fileInfo(file); @@ -412,6 +433,18 @@ QString RecognizeSystem::createFullPath(QString path) return fullPath; } +bool RecognizeSystem::checkIsChangeable() +{ + return updateController->getCurrentVersion()->getIsChangeable(); +} + +bool RecognizeSystem::checkNonStaticData(QString path) +{ + if(path.contains(sharedDataFolderName)) return true; + + return false; +} + RecognizeSystem::~RecognizeSystem() { diff --git a/ServerLMS/Systems/recognizesystem.h b/ServerLMS/Systems/recognizesystem.h index 7d5c97c..29a2b24 100644 --- a/ServerLMS/Systems/recognizesystem.h +++ b/ServerLMS/Systems/recognizesystem.h @@ -61,5 +61,7 @@ private: void packetTypeInit(PacketType packet,Client *client); void packetTypeInit(PacketType type); QString createFullPath(QString path); + bool checkIsChangeable(); + bool checkNonStaticData(QString path); }; #endif // RECOGNIZESYSTEM_H diff --git a/ServerLMS/Systems/tools.h b/ServerLMS/Systems/tools.h index e896664..1b9199d 100644 --- a/ServerLMS/Systems/tools.h +++ b/ServerLMS/Systems/tools.h @@ -27,6 +27,7 @@ static const QString clientHash = staticDataFolderName + "/clientHash.xml"; static const QString baseNameVersion = "base";//может вынести комманды куда нибудь? static const QString commandTryBaseDelete = "BASEDELETETRY"; +static const QString commandTryBaseChange = "TRYBASECHANGE"; static const QString commandTryActiveDelete = "TRYACTIVEDELETE"; static const QString commandTryCopyWithSameNames = "SAMENAMES"; static const QString commandGetServerDataList = "GETSERVERDATALIST"; @@ -35,6 +36,9 @@ static const QString commandReadyClient = "READY"; static const QString commandDisableClient = "DISABLE"; static const QString commandDuplicateVerName = "DUPLICATEVERNAME"; static const QString commandHashCompleteClient = "HASHSENDCOMPLETE"; +static const QString commandCanChangeVersion = "CANCHANGE"; +static const QString commandChangable = "CHANGEABLE"; +static const QString commandUnchangable = "UNCHANGEABLE"; static const QString commandUpdateFilesClient = "update"; class Tools { diff --git a/ServerLMS/Systems/updatecontroller.cpp b/ServerLMS/Systems/updatecontroller.cpp index 08c7e9c..2b66318 100644 --- a/ServerLMS/Systems/updatecontroller.cpp +++ b/ServerLMS/Systems/updatecontroller.cpp @@ -431,6 +431,15 @@ void UpdateController::calculateSharedHash() fileInfo.absoluteFilePath(),fileInfo.fileName(), fileInfo.birthTime(),fileInfo.size()); + if(fileInfo.fileName() == baseNameVersion) + { + version->setIsChangeable(false); + } + else + { + version->setIsChangeable(true); + } + versionList->append(version); } @@ -447,8 +456,9 @@ void UpdateController::createVersionListXmlAnswer(QList { SAttribute attribute1 = {"Version", ver->getViewName()}; SAttribute attribute2 = {"Created", ver->getCreateData().toString()}; + SAttribute attribute3 = {"isChangeable",QString::number(ver->getIsChangeable())}; - QList listAttr = {attribute1, attribute2}; + QList listAttr = {attribute1, attribute2,attribute3}; SXmlAnswerTag tag = {"VersionData", listAttr}; listTag.append(tag); @@ -492,6 +502,7 @@ void UpdateController::saveVersionToFile(StreamingVersionData *streamingVersion) xmlWriter.writeStartElement("VersionData"); xmlWriter.writeAttribute("Version",streamingVersion->getViewName()); xmlWriter.writeAttribute("Created",streamingVersion->getCreateData().toString()); + xmlWriter.writeAttribute("isChangeable",QString::number(streamingVersion->getIsChangeable())); xmlWriter.writeEndElement(); xmlWriter.writeEndDocument(); @@ -543,6 +554,11 @@ void UpdateController::xmlFileDataParse(QByteArray array) } } +StreamingVersionData* UpdateController::getCurrentVersion() +{ + return assetManager->getCurrentVersionData(); +} + void UpdateController::printFileList(QList fileData) { QListIterator iterator(fileData); diff --git a/ServerLMS/Systems/updatecontroller.h b/ServerLMS/Systems/updatecontroller.h index efe3aee..6932588 100644 --- a/ServerLMS/Systems/updatecontroller.h +++ b/ServerLMS/Systems/updatecontroller.h @@ -54,6 +54,7 @@ public: void createVersionListXmlAnswer(QList version); void saveVersionToFile(StreamingVersionData *streamingVersion); void xmlFileDataParse(QByteArray array); + StreamingVersionData *getCurrentVersion(); public slots: void changeAssetVersion(QString versionName); void createCopyVersion(QString versionName,QString newVersionName); diff --git a/ServerLMS/serverlmswidget.cpp b/ServerLMS/serverlmswidget.cpp index b90a0c3..4f8c27f 100644 --- a/ServerLMS/serverlmswidget.cpp +++ b/ServerLMS/serverlmswidget.cpp @@ -70,7 +70,7 @@ ServerLMSWidget::ServerLMSWidget(QWidget *parent) : updateThread->start(); commonClientHandler->initialize(&clientsMap,processingSystem,dataParser,logger); - processingSystem->initialize(this,dataParser,commonClientHandler,logger); + processingSystem->initialize(this,dataParser,commonClientHandler,logger,updateController); logger->setTypeLog("widget");