mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJClient.git
synced 2026-03-28 05:25:39 +03:00
fix: reconnect with old connection
This commit is contained in:
@@ -9,7 +9,7 @@ FastHashCalculator::FastHashCalculator(QObject *parent) : QObject(parent)
|
||||
void FastHashCalculator::calculateHashes(const QString& path, const QString& ignoreName)
|
||||
{
|
||||
hashList->clear();
|
||||
|
||||
currentSize = 0;
|
||||
if(!QDir(path).exists()){
|
||||
QDir().mkdir(path);
|
||||
}
|
||||
@@ -18,7 +18,7 @@ void FastHashCalculator::calculateHashes(const QString& path, const QString& ign
|
||||
QStringList filter;
|
||||
filter << "*";
|
||||
QList<FileData> *folders = new QList<FileData>;
|
||||
//QString fullSize = Tools::convertFileSize(getDirectorySize(path),false);
|
||||
fullSize = Tools::convertFileSize(getDirectorySize(path),false);
|
||||
|
||||
QDirIterator dirIterator(path,filter, QDir::AllEntries, QDirIterator::Subdirectories);
|
||||
|
||||
@@ -80,18 +80,45 @@ QByteArray FastHashCalculator::calculateFileHashOptimized(const QString &filePat
|
||||
if (!file.open(QIODevice::ReadOnly)) return QByteArray();
|
||||
|
||||
QCryptographicHash hash(QCryptographicHash::Md5);
|
||||
const qint64 bufferSize = 2 * 1024; // 2MB
|
||||
const qint64 bufferSize = 2048; // 2MB
|
||||
quint64 completeBytes = 0;
|
||||
QByteArray buffer;
|
||||
buffer.resize(bufferSize);
|
||||
|
||||
while (!file.atEnd()) {
|
||||
qint64 bytesRead = file.read(buffer.data(), bufferSize);
|
||||
hash.addData(buffer.constData(), bytesRead);
|
||||
completeBytes += bytesRead;
|
||||
}
|
||||
|
||||
hashCounterDisplay(completeBytes);
|
||||
return hash.result();
|
||||
}
|
||||
|
||||
void FastHashCalculator::hashCounterDisplay(quint64 size)
|
||||
{
|
||||
currentSize += size;
|
||||
emit sigSendHashInfo(fullSize,Tools::convertFileSize(currentSize,false));
|
||||
}
|
||||
|
||||
quint64 FastHashCalculator::getDirectorySize(const QString& path)
|
||||
{
|
||||
quint64 totalSize = 0;
|
||||
QDirIterator iterator(path, QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
iterator.next();
|
||||
QFileInfo fileInfo = iterator.fileInfo();
|
||||
if (fileInfo.isFile())
|
||||
{
|
||||
totalSize += fileInfo.size();
|
||||
}
|
||||
}
|
||||
|
||||
return totalSize;
|
||||
}
|
||||
|
||||
QList<FileData> *FastHashCalculator::getHashList() const
|
||||
{
|
||||
return hashList;
|
||||
|
||||
Reference in New Issue
Block a user