summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/updatewindow.cpp14
-rw-r--r--src/gui/updatewindow.h2
2 files changed, 15 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;
+}
diff --git a/src/gui/updatewindow.h b/src/gui/updatewindow.h
index 1246c9b35..13b72f3a8 100644
--- a/src/gui/updatewindow.h
+++ b/src/gui/updatewindow.h
@@ -136,6 +136,8 @@ private:
static size_t memoryWrite(void *ptr, size_t size, size_t nmemb,
void *stream);
+ bool validateFile(std::string filePath, long hash);
+
enum UpdateDownloadStatus
{
UPDATE_ERROR = 0,