feat: update controller add sort

This commit is contained in:
semenov
2024-12-17 12:56:20 +03:00
parent b9f7ef3369
commit 7aeb9d8000
16 changed files with 165 additions and 340 deletions

View File

@@ -12,8 +12,9 @@ UpdateController::UpdateController(DataParser *parser,SendSystem *sendSystem, QO
void UpdateController::calculateCommonHash()
{
appDataList.clear();
appDataList = calculateHash(applicationFolderPath);
appDataList = calculateHash(applicationFolderPath,"StreamingAssets");
calculateStreamingHash();
appDataList.append(streamingDataList);
dataParser->createFileDataList(appDataList,hashFilename);
qDebug() << "UpdateController threadID " << QThread::currentThreadId();
}
@@ -21,8 +22,9 @@ void UpdateController::calculateCommonHash()
void UpdateController::calculateStreamingHash()
{
streamingDataList.clear();
streamingDataList = calculateHash(QDir::currentPath() + streamingAssetsPath);
dataParser->createFileDataList(appDataList,streamingHashFilename);
streamingDataList = calculateHash(QDir::currentPath() + streamingAssetsPath,"");
std::sort(streamingDataList.begin(),streamingDataList.end());
dataParser->createFileDataList(streamingDataList,streamingHashFilename);
}
void UpdateController::setServerVersion(StreamingVersionData *version)
@@ -30,7 +32,7 @@ void UpdateController::setServerVersion(StreamingVersionData *version)
serverVersion = version;
}
QList<FileData> UpdateController::calculateHash(QString path)
QList<FileData> UpdateController::calculateHash(QString path,QString ignoreName)
{
qDebug() << "Try calculate";
@@ -56,6 +58,7 @@ QList<FileData> UpdateController::calculateHash(QString path)
const quint64 bufferSize = 10240;
if(fileInfo.isHidden()) continue;
if(ignoreName != "" && fileInfo.path().contains(ignoreName)) continue;
if(fileInfo.isFile() && file.open(QIODevice::ReadOnly))
{
@@ -90,6 +93,8 @@ QList<FileData> UpdateController::calculateHash(QString path)
}
std::sort(hashes->begin(),hashes->end());
return *hashes;
}