From 71cc441b9e742c135b19bda941f384bcaf052112 Mon Sep 17 00:00:00 2001
From: Nikias Bassen
Date: Thu, 14 Feb 2019 01:33:35 +0100
Subject: win32: Workaround for _lseeki64 not seeking as expected...

NO COMMENT
---
 src/asr.c      | 3 +++
 src/download.c | 1 +
 2 files changed, 4 insertions(+)

diff --git a/src/asr.c b/src/asr.c
index 3800c2b..22192fe 100644
--- a/src/asr.c
+++ b/src/asr.c
@@ -207,6 +207,7 @@ int asr_perform_validation(asr_client_t asr, const char* filesystem) {
 #ifdef WIN32
 	length = _lseeki64(fileno(file), 0, SEEK_END);
 	_lseeki64(fileno(file), 0, SEEK_SET);
+	rewind(file);
 #else
 	fseeko(file, 0, SEEK_END);
 	length = ftello(file);
@@ -306,6 +307,7 @@ int asr_handle_oob_data_request(asr_client_t asr, plist_t packet, FILE* file) {
 	}
 
 #ifdef WIN32
+	rewind(file);
 	_lseeki64(fileno(file), oob_offset, SEEK_SET);
 #else
 	fseeko(file, oob_offset, SEEK_SET);
@@ -342,6 +344,7 @@ int asr_send_payload(asr_client_t asr, const char* filesystem) {
 #ifdef WIN32
 	length = _lseeki64(fileno(file), 0, SEEK_END);
 	_lseeki64(fileno(file), 0, SEEK_SET);
+	rewind(file);
 #else
 	fseeko(file, 0, SEEK_END);
 	length = ftello(file);
diff --git a/src/download.c b/src/download.c
index b50abc1..2194091 100644
--- a/src/download.c
+++ b/src/download.c
@@ -140,6 +140,7 @@ int download_to_file(const char* url, const char* filename, int enable_progress)
 	curl_easy_cleanup(handle);
 
 #ifdef WIN32
+	fflush(f);
 	uint64_t sz = _lseeki64(fileno(f), 0, SEEK_CUR);
 #else
 	off_t sz = ftello(f);
-- 
cgit v1.1-32-gdbae