mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJClient.git
synced 2026-03-28 05:25:39 +03:00
feat: add files time
This commit is contained in:
@@ -93,6 +93,7 @@ void DataParserOutput::createFileDataList(const QList<FileData>& fileDataList,co
|
||||
|
||||
xmlWriter.writeAttribute("Path",data.path);
|
||||
xmlWriter.writeAttribute("Hash",data.hash);
|
||||
xmlWriter.writeAttribute("LastUpdate",data.lastUpdate);
|
||||
|
||||
xmlWriter.writeEndElement();
|
||||
}
|
||||
@@ -333,6 +334,8 @@ QList<FileData>* DataParserOutput::xmlFileDataParse(const QByteArray& array,cons
|
||||
data.path = value;
|
||||
else if(name == "Hash")
|
||||
data.hash = value;
|
||||
else if(name == "LastUpdate")
|
||||
data.lastUpdate = value;
|
||||
}
|
||||
|
||||
if(data.path.contains(filter))
|
||||
|
||||
@@ -61,6 +61,7 @@ void FastHashCalculator::calculateHashes(const QString& path, const QString& ign
|
||||
|
||||
QtConcurrent::map(files, [this](const QString &filePath)
|
||||
{
|
||||
QFileInfo fileInfo(filePath);
|
||||
QByteArray hash = calculateFileHashOptimized(filePath);
|
||||
QMutexLocker locker(&_mutex);
|
||||
FileData currentFile;
|
||||
@@ -68,7 +69,7 @@ void FastHashCalculator::calculateHashes(const QString& path, const QString& ign
|
||||
|
||||
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();
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ void HashComparer::initialize(VersionContainer *versionContainer,UpdateNotifyWid
|
||||
void HashComparer::CompareDeltas(QList<FileData> *serverStreamingHash, QList<FileData> localStreamingHash)
|
||||
{
|
||||
QList<FileData> *files = new QList<FileData>;
|
||||
|
||||
serverFiles = new QList<FileData>;
|
||||
QMutableListIterator<FileData> iterator(localStreamingHash);
|
||||
|
||||
for (auto &item:localStreamingHash)
|
||||
@@ -26,6 +26,8 @@ void HashComparer::CompareDeltas(QList<FileData> *serverStreamingHash, QList<Fil
|
||||
if(!serverStreamingHash->contains(item))
|
||||
{
|
||||
if (item.path.contains("docs.xml")) continue; //фильтр на docs
|
||||
quint32 fileDataIndex = findIndexByPath(*serverStreamingHash, item.path);
|
||||
serverFiles->append(serverStreamingHash->at(fileDataIndex));
|
||||
files->append(item);
|
||||
}
|
||||
}
|
||||
@@ -34,6 +36,17 @@ void HashComparer::CompareDeltas(QList<FileData> *serverStreamingHash, QList<Fil
|
||||
showDeltas();
|
||||
}
|
||||
|
||||
quint32 HashComparer::findIndexByPath(const QList<FileData> &serverStreamingHash,QString path)
|
||||
{
|
||||
for(int i = 0; i < serverStreamingHash.size(); i++)
|
||||
{
|
||||
if(serverStreamingHash.at(i).path == path)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void HashComparer::showDeltas()
|
||||
{
|
||||
|
||||
@@ -42,9 +55,12 @@ void HashComparer::showDeltas()
|
||||
emit sigCallCheck();
|
||||
return;
|
||||
}
|
||||
for (auto &item:*filesForUpdate)
|
||||
|
||||
for (int i = 0; i < filesForUpdate->size(); i++)
|
||||
{
|
||||
updateWidget->addToList(item);
|
||||
FileData local = filesForUpdate->at(i);
|
||||
FileData server = serverFiles->at(i);
|
||||
updateWidget->addToList(local,server);
|
||||
}
|
||||
|
||||
emit sigHaveDelta();
|
||||
|
||||
@@ -26,7 +26,9 @@ signals:
|
||||
private:
|
||||
UpdateNotifyWidget* updateWidget;
|
||||
QList<FileData> *filesForUpdate;
|
||||
QList<FileData> *serverFiles;
|
||||
VersionContainer *versionContainer;
|
||||
quint32 findIndexByPath(const QList<FileData> &serverStreamingHash, QString path);
|
||||
};
|
||||
|
||||
#endif // HASHCOMPARER_H
|
||||
|
||||
Reference in New Issue
Block a user