summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugenio Favalli <elvenprogrammer@gmail.com>2007-02-01 21:26:20 +0000
committerEugenio Favalli <elvenprogrammer@gmail.com>2007-02-01 21:26:20 +0000
commitc920d8e57980dfc17702fd510e3cfa244a58d878 (patch)
treee8e08ebdcad35e12afcf670a026bbeb1f998daa0
parent7193be01bb2a04f02880a42bcacc2b2ec39acf29 (diff)
downloadmana-c920d8e57980dfc17702fd510e3cfa244a58d878.tar.gz
mana-c920d8e57980dfc17702fd510e3cfa244a58d878.tar.bz2
mana-c920d8e57980dfc17702fd510e3cfa244a58d878.tar.xz
mana-c920d8e57980dfc17702fd510e3cfa244a58d878.zip
File handle should be closed before attempting to remove/rename files.
-rw-r--r--ChangeLog7
-rw-r--r--src/gui/updatewindow.cpp20
2 files changed, 16 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index cd6f2370..b3ca128e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,9 @@
-2007-02-01 Bjørn Lindeijer <bjorn@lindeijer.nl>
+2007-02-01 Eugenio Favalli <elvenprogrammer@gmail.com>
+
+ * src/gui/updatewindow.cpp: File handle should be closed before
+ attempting to remove/rename files.
+
+2007-02-01 Bjørn Lindeijer <bjorn@lindeijer.nl>
* src/gui/updatewindow.cpp, src/gui/updatewindow.h: A bit of cleanup
and defined a helper function for calculating the alder32 checksum of
diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp
index 670baf29..c763e488 100644
--- a/src/gui/updatewindow.cpp
+++ b/src/gui/updatewindow.cpp
@@ -332,15 +332,6 @@ int UpdaterWindow::downloadThread(void *ptr)
if (!uw->mStoreInMemory)
{
- // Give the file the proper name
- std::string newName(uw->mBasePath + "/updates/" +
- uw->mCurrentFile.c_str());
-
- // Any existing file with this name is deleted first, otherwise
- // the rename will fail on Windows.
- ::remove(newName.c_str());
- ::rename(outFilename.c_str(), newName.c_str());
-
// Don't check resources2.txt checksum
if (uw->mDownloadStatus == UPDATE_RESOURCES)
{
@@ -350,7 +341,7 @@ int UpdaterWindow::downloadThread(void *ptr)
{
uw->mDownloadComplete = false;
// Remove the corrupted file
- ::remove(newName.c_str());
+ ::remove(outFilename.c_str());
logger->log(
"Checksum for file %s failed: (%lx/%lx)",
uw->mCurrentFile.c_str(),
@@ -359,6 +350,15 @@ int UpdaterWindow::downloadThread(void *ptr)
}
fclose(outfile);
+
+ // Give the file the proper name
+ std::string newName(uw->mBasePath + "/updates/" +
+ uw->mCurrentFile.c_str());
+
+ // Any existing file with this name is deleted first, otherwise
+ // the rename will fail on Windows.
+ ::remove(newName.c_str());
+ ::rename(outFilename.c_str(), newName.c_str());
}
}
attempts++;