feat: add file data complete

This commit is contained in:
semenov
2026-03-11 11:46:11 +03:00
parent 74937bc64d
commit 6bfe260e47
6 changed files with 16 additions and 2 deletions

View File

@@ -19,6 +19,7 @@ struct FileData
{
QString path;
QString hash;
QString lastUpdate;
bool operator==(const FileData& other)const
{

View File

@@ -61,6 +61,8 @@ void FastHashCalculator::calculateHashes(QString path)
QtConcurrent::map(files, [this](const QString &filePath)
{
QFileInfo fileinfo(filePath);
QByteArray hash = calculateFileHashOptimized(filePath);
QMutexLocker locker(&_mutex);
FileData currentFile;
@@ -68,6 +70,7 @@ void FastHashCalculator::calculateHashes(QString path)
currentFile.path = Tools::createLocalPath(filePath);
currentFile.hash = hash.toHex();
currentFile.lastUpdate = fileinfo.fileTime(QFileDevice::FileModificationTime).toString("dd.MM.yyyy hh:mm:ss");
hashList->append(currentFile);
}).waitForFinished();

View File

@@ -149,6 +149,7 @@ void UpdateController::saveHash(QString fileName,QList<FileData> *fileList)
xmlWriter.writeAttribute("Path",data.path);
xmlWriter.writeAttribute("Hash",data.hash);
xmlWriter.writeAttribute("LastUpdate",data.lastUpdate);
xmlWriter.writeEndElement();
}
@@ -162,6 +163,7 @@ void UpdateController::saveHash(QString fileName,QList<FileData> *fileList)
QList<FileData>* UpdateController::loadHash(QString filename)
{
//TODO: дублируется функционал DataParser
QList<FileData> *files = new QList<FileData>();
QFile hashFile(filename);
@@ -190,6 +192,8 @@ QList<FileData>* UpdateController::loadHash(QString filename)
data.path = value;
else if(name == "Hash")
data.hash = value;
else if(name == "LastUpdate")
data.lastUpdate = value;
}
files->append(data);