summaryrefslogtreecommitdiff
path: root/src/gui/updatewindow.cpp
diff options
context:
space:
mode:
authorRogier Polak <rogier.l.a.polak@gmail.com>2007-02-16 15:07:56 +0000
committerRogier Polak <rogier.l.a.polak@gmail.com>2007-02-16 15:07:56 +0000
commit8074cb39623f844ac3e24b2c4b11a1165fa67900 (patch)
tree48d6c1409bc52edc869e1a2b065199d5054354c6 /src/gui/updatewindow.cpp
parentc229a5f66384a441c3cd878a39822b219301133c (diff)
downloadmana-8074cb39623f844ac3e24b2c4b11a1165fa67900.tar.gz
mana-8074cb39623f844ac3e24b2c4b11a1165fa67900.tar.bz2
mana-8074cb39623f844ac3e24b2c4b11a1165fa67900.tar.xz
mana-8074cb39623f844ac3e24b2c4b11a1165fa67900.zip
Fixed update bug (hopefully)
Diffstat (limited to 'src/gui/updatewindow.cpp')
-rw-r--r--src/gui/updatewindow.cpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp
index c763e488..45211b3e 100644
--- a/src/gui/updatewindow.cpp
+++ b/src/gui/updatewindow.cpp
@@ -268,6 +268,7 @@ int UpdaterWindow::downloadThread(void *ptr)
while (attempts < 3 && !uw->mDownloadComplete)
{
FILE *outfile = NULL;
+ FILE *newfile = NULL;
uw->setLabel(uw->mCurrentFile + " (0%)");
curl = curl_easy_init();
@@ -328,10 +329,9 @@ int UpdaterWindow::downloadThread(void *ptr)
curl_easy_cleanup(curl);
- uw->mDownloadComplete = true;
-
if (!uw->mStoreInMemory)
{
+
// Don't check resources2.txt checksum
if (uw->mDownloadStatus == UPDATE_RESOURCES)
{
@@ -339,16 +339,18 @@ int UpdaterWindow::downloadThread(void *ptr)
if (uw->mCurrentChecksum != adler)
{
- uw->mDownloadComplete = false;
+ fclose(outfile);
+
// Remove the corrupted file
::remove(outFilename.c_str());
logger->log(
"Checksum for file %s failed: (%lx/%lx)",
uw->mCurrentFile.c_str(),
adler, uw->mCurrentChecksum);
+ attempts++;
+ continue; //Bail out her to avoid the renaming
}
}
-
fclose(outfile);
// Give the file the proper name
@@ -359,6 +361,18 @@ int UpdaterWindow::downloadThread(void *ptr)
// the rename will fail on Windows.
::remove(newName.c_str());
::rename(outFilename.c_str(), newName.c_str());
+
+ //Check if we can open it and no errors were encountered during renaming
+ newfile = fopen(newName.c_str(), "rb");
+ if (newfile)
+ {
+ fclose(newfile);
+ uw->mDownloadComplete = true;
+ }
+ }
+ else
+ {
+ uw->mDownloadComplete = true; // it's stored in memory, we're done
}
}
attempts++;
@@ -420,7 +434,7 @@ void UpdaterWindow::logic()
mCurrentFile = "resources2.txt";
mStoreInMemory = false;
mDownloadStatus = UPDATE_LIST;
- download();
+ download(); //download() changes mDownloadComplete to false
}
break;
case UPDATE_LIST: