summaryrefslogtreecommitdiff
path: root/src/gui/updatewindow.cpp
diff options
context:
space:
mode:
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;
+}