summaryrefslogtreecommitdiff
path: root/src/net/download.h
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-02-29 17:25:29 +0100
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-02-29 17:25:29 +0100
commit2e60491ceb0548b0bea93207c13b974d6a6cf5cc (patch)
tree43ea8aefa4aa1646df82a5163b9cdae0a39df48e /src/net/download.h
parentdd1db3753ecf8a4d782aee1f518759763d8caf87 (diff)
downloadMana-2e60491ceb0548b0bea93207c13b974d6a6cf5cc.tar.gz
Mana-2e60491ceb0548b0bea93207c13b974d6a6cf5cc.tar.bz2
Mana-2e60491ceb0548b0bea93207c13b974d6a6cf5cc.tar.xz
Mana-2e60491ceb0548b0bea93207c13b974d6a6cf5cc.zip
Re-download updates when their checksum no longer matches
The Mana World currently likes to just update its "TMW.zip" file, whereas updates were always given unique names in the past. With this change, the client checks the Adler32 checksum to know when it should re-download an update file. This matches the behavior of ManaPlus commit 96150f1aeacf55d311c41ffe12d9e754b1cda001.
Diffstat (limited to 'src/net/download.h')
-rw-r--r--src/net/download.h11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/net/download.h b/src/net/download.h
index 500de0b6..0ce8cc8a 100644
--- a/src/net/download.h
+++ b/src/net/download.h
@@ -21,6 +21,7 @@
#include <cstdlib> // pulls in int64_t
#include <cstdio>
#include <string>
+#include <optional>
#include <curl/curl.h>
@@ -61,7 +62,8 @@ class Download
*/
void noCache();
- void setFile(const std::string &filename, int64_t adler32 = -1);
+ void setFile(const std::string &filename,
+ std::optional<unsigned long> adler32 = {});
void setWriteFunction(WriteFunction write);
@@ -79,7 +81,9 @@ class Download
*/
void cancel();
- char *getError();
+ const char *getError() const;
+
+ static unsigned long fadler32(FILE *file);
private:
static int downloadThread(void *ptr);
@@ -91,11 +95,10 @@ class Download
struct {
unsigned cancel : 1;
unsigned memoryWrite: 1;
- unsigned checkAdler: 1;
} mOptions;
std::string mFileName;
WriteFunction mWriteFunction = nullptr;
- unsigned long mAdler;
+ std::optional<unsigned long> mAdler;
DownloadUpdate mUpdateFunction;
SDL_Thread *mThread = nullptr;
CURL *mCurl = nullptr;