From d2ec916793974c4a49396ff236ccfae1c02e4b29 Mon Sep 17 00:00:00 2001 From: semenov Date: Wed, 23 Jul 2025 13:21:56 +0300 Subject: [PATCH] bugfix: fast change version --- ServerLMS/Systems/updatecontroller.cpp | 40 +++++++++++++------------- ServerLMS/Systems/updatecontroller.h | 3 +- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/ServerLMS/Systems/updatecontroller.cpp b/ServerLMS/Systems/updatecontroller.cpp index 2ebe0c7..5fc1c00 100644 --- a/ServerLMS/Systems/updatecontroller.cpp +++ b/ServerLMS/Systems/updatecontroller.cpp @@ -65,7 +65,8 @@ void UpdateController::deleteAssetVersion(QString versionName) void UpdateController::compareFiles(ClientHandler* handler, QByteArray array) { mutex->lock(); - loadHash(); + serverDataList.clear(); + serverDataList = *loadHash(hashFileName); clientDataList.clear(); xmlFileDataParse(array); checkNeedUpdate(handler); @@ -95,7 +96,7 @@ void UpdateController::calculateFullHash() void UpdateController::calculateFullHashWithSetup() { commonClientHandler->slot_sendPacketToAllClients(PacketType::HASH_CALCULATE_START); - calculateFullHash(); + calculateCurrentSharedHash(); setUpCurrentServerHash(); commonClientHandler->slot_sendPacketToAllClients(PacketType::HASH_READY); } @@ -129,11 +130,11 @@ void UpdateController::saveHash(QString fileName,QList *fileList) } -void UpdateController::loadHash() +QList* UpdateController::loadHash(QString filename) { - serverDataList.clear(); + QList *files = new QList(); - QFile hashFile(hashFileName); + QFile hashFile(filename); QByteArray array; if(hashFile.open(QIODevice::ReadOnly)){ array = hashFile.readAll(); @@ -161,7 +162,7 @@ void UpdateController::loadHash() data.hash = value; } - serverDataList.append(data); + files->append(data); } } @@ -171,6 +172,8 @@ void UpdateController::loadHash() emit sigLogMessage("Hash load from file "); + return files; + } void UpdateController::calculateSize() @@ -203,12 +206,13 @@ QString UpdateController::getCommands() void UpdateController::setUpCurrentServerHash() { QList *fileList = new QList; - fileList->append(*calculateHash(buildPath)); + fileList->append(*loadHash(buildHashName)); FileData *streamingFolder = new FileData; streamingFolder->hash = "FOLDER"; streamingFolder->path = buildDataPath + streamingAssetsFolderName; fileList->append(*streamingFolder); - fileList->append(*calculateHash(currentStreamingPath)); + QString streamingHashFileName = Tools::createVersionHashFilepath(assetManager->getCurrentVersionData()->getViewName()); + fileList->append(*loadHash(streamingHashFileName)); assetManager->prepareLocalPathList(fileList); saveHash(hashFileName,fileList); @@ -462,23 +466,19 @@ void UpdateController::calculateSharedHash() StreamingVersionData *version = new StreamingVersionData( fileInfo.absoluteFilePath(),fileInfo.fileName(), fileInfo.birthTime(),fileInfo.size()); - -// if(fileInfo.fileName() == baseNameVersion) -// { -// version->setIsChangeable(false); -// version->setAuthor(tr("Константа-дизайн")); -// } -// else -// { -// version->setIsChangeable(true); -// } - versionList->append(version); } assetManager->createFirstVersionListXML(*versionList); - //assetManager->setVersionList(versionList); +} + +void UpdateController::calculateCurrentSharedHash() +{ + QList *fileList = new QList; + QString fileName = Tools::createVersionHashFilepath(assetManager->getCurrentVersionData()->getViewName()); + fileList = calculateHash(currentStreamingPath); + saveHash(fileName,fileList); } void UpdateController::sendNewVersionList() diff --git a/ServerLMS/Systems/updatecontroller.h b/ServerLMS/Systems/updatecontroller.h index 5daf24e..b3046dc 100644 --- a/ServerLMS/Systems/updatecontroller.h +++ b/ServerLMS/Systems/updatecontroller.h @@ -96,9 +96,10 @@ private: void setLocalFileData(QList dataList); void calculateSize(); void saveHash(QString fileName,QList *fileList); - void loadHash(); + QList* loadHash(QString fileName); void CalculateSizeToSend(QList diffList); bool checkRequiredFolder(); + void calculateCurrentSharedHash(); }; #endif // UPDATECONTROLLER_H