diff options
author | Eugenio Favalli <elvenprogrammer@gmail.com> | 2007-02-01 21:26:20 +0000 |
---|---|---|
committer | Eugenio Favalli <elvenprogrammer@gmail.com> | 2007-02-01 21:26:20 +0000 |
commit | c920d8e57980dfc17702fd510e3cfa244a58d878 (patch) | |
tree | e8e08ebdcad35e12afcf670a026bbeb1f998daa0 | |
parent | 7193be01bb2a04f02880a42bcacc2b2ec39acf29 (diff) | |
download | mana-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-- | ChangeLog | 7 | ||||
-rw-r--r-- | src/gui/updatewindow.cpp | 20 |
2 files changed, 16 insertions, 11 deletions
@@ -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++; |