summaryrefslogtreecommitdiff
path: root/client/FileOpThread.cpp
diff options
context:
space:
mode:
authorAlex Borisov <borisov.alexandr@rambler.ru>2011-12-02 03:54:00 +0200
committerAlex Borisov <borisov.alexandr@rambler.ru>2011-12-02 03:54:00 +0200
commitbd1d34d7781d35f17666adb3df6abb7c9b7fcc32 (patch)
treec20440b674aff4189e4c2e1f24f644228b6ff27c /client/FileOpThread.cpp
parent8d6422572c9e531116eb7aea103a93f62f8ae3e2 (diff)
MD5 hash check for existing & downloaded files
Diffstat (limited to 'client/FileOpThread.cpp')
-rw-r--r--client/FileOpThread.cpp18
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
{