summaryrefslogtreecommitdiff
path: root/src/gui/updatewindow.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-02-26 21:48:31 +0200
committerAndrei Karas <akaras@inbox.ru>2011-02-26 21:48:31 +0200
commit96150f1aeacf55d311c41ffe12d9e754b1cda001 (patch)
tree94252db740b9c2b6ad8122523baa732c0b913fbc /src/gui/updatewindow.cpp
parent4c04665b29cd7304717cefe49d70d881d8b38ca3 (diff)
downloadplus-96150f1aeacf55d311c41ffe12d9e754b1cda001.tar.gz
plus-96150f1aeacf55d311c41ffe12d9e754b1cda001.tar.bz2
plus-96150f1aeacf55d311c41ffe12d9e754b1cda001.tar.xz
plus-96150f1aeacf55d311c41ffe12d9e754b1cda001.zip
Add ability to redownload update files if file checksum incorrect.
Diffstat (limited to 'src/gui/updatewindow.cpp')
-rw-r--r--src/gui/updatewindow.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp
index 132f8bcfc..f4281cff1 100644
--- a/src/gui/updatewindow.cpp
+++ b/src/gui/updatewindow.cpp
@@ -635,7 +635,8 @@ void UpdaterWindow::logic()
std::ifstream temp(
(mUpdatesDir + "/" + mCurrentFile).c_str());
- if (!temp.is_open())
+ if (!temp.is_open() || !validateFile(mUpdatesDir + "/"
+ + mCurrentFile, mCurrentChecksum))
{
temp.close();
download();
@@ -671,3 +672,14 @@ void UpdaterWindow::logic()
break;
}
}
+
+bool UpdaterWindow::validateFile(std::string filePath, long hash)
+{
+ FILE *file = fopen(filePath.c_str(), "rb");
+ if (!file)
+ return false;
+
+ unsigned long adler = Net::Download::fadler32(file);
+ fclose(file);
+ return adler == hash;
+}