23
23
#include " extractionworker.h"
24
24
#include " downloadworker.h"
25
25
#include " patchworker.h"
26
+ #include " utilities.h"
26
27
27
28
#include < QJsonObject>
28
29
#include < QJsonArray>
35
36
36
37
UpdateWorker::UpdateWorker (QObject *parent) : QObject(parent)
37
38
{
38
- hashWorker = new HashWorker (this );
39
-
40
39
QSettings settings (" Shticker-Book-Rewritten" , " Shticker-Book-Rewritten" );
41
40
42
41
settings.beginGroup (" FilesPath" );
@@ -96,7 +95,7 @@ void UpdateWorker::patchManifestReady(QJsonDocument patchManifest)
96
95
if (file.exists ())
97
96
{
98
97
// generate the SHA1 hash of the file to compare with the patch manifest
99
- fileHash = hashWorker-> getHash (localFileName);
98
+ fileHash = getHash (localFileName);
100
99
qDebug () << " Local file's hash is:" << fileHash;
101
100
102
101
// Check if the hash matches the patch manifest
@@ -129,7 +128,7 @@ void UpdateWorker::patchManifestReady(QJsonDocument patchManifest)
129
128
getNewFile (patchObject[" filename" ].toString (), patchFileName, extractedFileName, patchObject[" compPatchHash" ].toString ());
130
129
131
130
// verify the downloaded patch is good
132
- if (hashWorker-> getHash (extractedFileName) == patchObject[" patchHash" ].toString ())
131
+ if (getHash (extractedFileName) == patchObject[" patchHash" ].toString ())
133
132
{
134
133
qDebug () << " Downloaded patch matches manifest" ;
135
134
}
@@ -144,7 +143,7 @@ void UpdateWorker::patchManifestReady(QJsonDocument patchManifest)
144
143
hasBeenPatched = true ;
145
144
146
145
// check if the patch updated the file fully
147
- if (hashWorker-> getHash (localFileName) == fileObject[" hash" ].toString ())
146
+ if (getHash (localFileName) == fileObject[" hash" ].toString ())
148
147
{
149
148
qDebug () << " File has been patched fully\n " ;
150
149
fileIsOld = false ;
@@ -167,7 +166,7 @@ void UpdateWorker::patchManifestReady(QJsonDocument patchManifest)
167
166
getNewFile (fileObject[" dl" ].toString (), localBz2FileName, localFileName, fileObject[" compHash" ].toString ());
168
167
169
168
// check to make sure it is up to date
170
- fileHash = hashWorker-> getHash (localFileName);
169
+ fileHash = getHash (localFileName);
171
170
if (fileHash == fileObject[" hash" ].toString ())
172
171
{
173
172
qDebug () << " Downloaded file's integrity has been verified\n " ;
@@ -188,7 +187,7 @@ void UpdateWorker::patchManifestReady(QJsonDocument patchManifest)
188
187
getNewFile (fileObject[" dl" ].toString (), localBz2FileName, localFileName, fileObject[" compHash" ].toString ());
189
188
190
189
// check to make sure it is up to date
191
- fileHash = hashWorker-> getHash (localFileName);
190
+ fileHash = getHash (localFileName);
192
191
if (fileHash == fileObject[" hash" ].toString ())
193
192
{
194
193
qDebug () << " Downloaded file's integrity has been verified\n " ;
@@ -269,7 +268,7 @@ void UpdateWorker::getNewFile(QString dlFile, QString localBz2FileName, QString
269
268
startDownload (dlFile);
270
269
271
270
// make sure download succeeded, logging for debugging purposes but still extracting because TTR has been known to not update hashes
272
- QByteArray fileHash = hashWorker-> getHash (localBz2FileName);
271
+ QByteArray fileHash = getHash (localBz2FileName);
273
272
274
273
if (fileHash == compHash)
275
274
{
0 commit comments