diff options
Diffstat (limited to 'client/FileOpThread.cpp')
-rw-r--r-- | client/FileOpThread.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/client/FileOpThread.cpp b/client/FileOpThread.cpp index 3340db2..bd0b929 100644 --- a/client/FileOpThread.cpp +++ b/client/FileOpThread.cpp @@ -3,6 +3,7 @@ #include "DownloadClient.h" #include "FileOpThread.h" #include "UpdatedConfig.h" +#include "Utility.h" FileOpThread::~FileOpThread() @@ -44,9 +45,20 @@ void FileOpThread::run() if (fileInfo.exists()) { Logger::Info("File \"%s\" already exists\n", downloadList[i].path.c_str()); - /** - * @todo Compute md5 hash and check if they are the same - */ + QString filename = QString::fromLocal8Bit(downloadList[i].path.c_str()); + QString md5string = QString::fromLocal8Bit(downloadList[i].md5.c_str()); + QByteArray md5 = md5_sum(filename); + + if (md5 == md5string) + { + Logger::Trace("File %s is correct!\n", filename.toStdString().c_str()); + } + else + { + Logger::Error("File %s is incorrect or was updated. Need to download again!\n", filename.toStdString().c_str()); + pair<string, string> file = make_pair(downloadList[i].path, downloadList[i].md5); + files.push_back(file); + } } else { |