summaryrefslogtreecommitdiff
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
parentc229a5f66384a441c3cd878a39822b219301133c (diff)
downloadmana-8074cb39623f844ac3e24b2c4b11a1165fa67900.tar.gz
mana-8074cb39623f844ac3e24b2c4b11a1165fa67900.tar.bz2
mana-8074cb39623f844ac3e24b2c4b11a1165fa67900.tar.xz
mana-8074cb39623f844ac3e24b2c4b11a1165fa67900.zip
Fixed update bug (hopefully)
-rw-r--r--ChangeLog6
-rw-r--r--src/gui/updatewindow.cpp24
2 files changed, 25 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 3117b486..fb55e341 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-02-16 Rogier Polak <rogier.l.a.polak@gmail.com>
+
+ * src/gui/updatewindow.cpp: Fixed the update bug (hopefully), by
+ modifying the usage of the synchronisation between threads. Added
+ a check for existence of the updated file.
+
2007-02-15 Bjørn Lindeijer <bjorn@lindeijer.nl>
* src/winver.h, README, configure.ac, data/help/header.txt, NEWS,
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: