From c920d8e57980dfc17702fd510e3cfa244a58d878 Mon Sep 17 00:00:00 2001 From: Eugenio Favalli Date: Thu, 1 Feb 2007 21:26:20 +0000 Subject: File handle should be closed before attempting to remove/rename files. --- src/gui/updatewindow.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/gui/updatewindow.cpp') 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++; -- cgit v1.2.3-70-g09d2