forked from markus/S_New4
v3.2.8: fix missing removing file before rename in windows
This commit is contained in:
parent
a9f80ec4d1
commit
42f66b673f
@ -60,7 +60,7 @@ struct Settings {
|
||||
proxy_ip = "127.0.0.1",
|
||||
languages = "GerDub,GerSub,Eng",
|
||||
genaueHoster = "",
|
||||
version = "3.2.7",
|
||||
version = "3.2.8",
|
||||
defaultFileVersion="1.6",
|
||||
outputFilePath = "",
|
||||
default_checkPath = "",
|
||||
|
@ -1008,14 +1008,22 @@ int ProgramManager::updateModus(Settings *settings)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Download new Version of Program
|
||||
std::cout << " => INFO: Lade neue Version herunter..." << std::endl;
|
||||
|
||||
std::string downloadedFilePath = settings->cacheDir + "NeusteVersion" + ((settings->pathSymbol == '\\') ? ".exe" : "");
|
||||
if(fileExists(downloadedFilePath))
|
||||
if(remove(downloadedFilePath.c_str()) != 0) {
|
||||
perror("Failed to remove existing file");
|
||||
return 13;
|
||||
}
|
||||
|
||||
if( pageManager.downLoadToFile(downloadedFilePath, settings->ProgrammFileUrl) != 0) {
|
||||
std::cerr << " => Error: Download new Version failed." << std::endl;
|
||||
std::cerr << "\n => Error: Download new Version failed." << std::endl;
|
||||
return 3;
|
||||
}
|
||||
} std::cout << std::endl;
|
||||
|
||||
|
||||
//Make ist executable for test execution
|
||||
@ -1042,6 +1050,23 @@ int ProgramManager::updateModus(Settings *settings)
|
||||
return 6;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
std::cout << " => INFO: Verschiebe alte Version..." << std::endl;
|
||||
if(fileExists(settings->cacheDir + "oldVersion.exe")) {
|
||||
if(remove( (settings->cacheDir + "oldVersion.exe").c_str() ) != 0) {
|
||||
perror("Failed to remove existing file");
|
||||
return 14;
|
||||
}
|
||||
}
|
||||
if(rename(exePath.c_str(), (settings->cacheDir + "oldVersion.exe").c_str() ) != 0) {
|
||||
perror(("Mv '" + exePath + "' -> '" + settings->cacheDir + "oldVersion.exe' failed").c_str());
|
||||
return 7;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
std::cout << " => INFO: Ersetzte alte Version mit neuer Version des Programms..." << std::endl;
|
||||
|
||||
if(rename(downloadedFilePath.c_str(), exePath.c_str() ) != 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user