Fix autoupdate issue where temp file is not deleted, fixes #128
This commit is contained in:
parent
5b51e67044
commit
97a819c79c
@ -150,6 +150,10 @@ int update_finish(void)
|
||||
char *temp, *self=exe_name(), *p;
|
||||
int timeout = 60, err;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("Update: Current EXE name: %s\n", self);
|
||||
#endif
|
||||
|
||||
temp = (char*)malloc(strlen(self)+12);
|
||||
strcpy(temp, self);
|
||||
p = temp + strlen(temp) - 4;
|
||||
@ -157,12 +161,18 @@ int update_finish(void)
|
||||
p += 4;
|
||||
strcpy(p, "_update.exe");
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("Update: Temp EXE name: %s\n", temp);
|
||||
#endif
|
||||
|
||||
while (!DeleteFile(temp))
|
||||
{
|
||||
err = GetLastError();
|
||||
if (err == ERROR_FILE_NOT_FOUND)
|
||||
{
|
||||
// just as well, then
|
||||
#ifdef DEBUG
|
||||
printf("Update: Temp file deleted\n");
|
||||
#endif
|
||||
free(temp);
|
||||
return 0;
|
||||
}
|
||||
@ -170,6 +180,9 @@ int update_finish(void)
|
||||
timeout--;
|
||||
if (timeout <= 0)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("Update: Delete timeout\n");
|
||||
#endif
|
||||
free(temp);
|
||||
return 1;
|
||||
}
|
||||
|
@ -676,12 +676,8 @@ void Client::RemoveListener(ClientListener * listener)
|
||||
}
|
||||
}
|
||||
|
||||
void Client::Shutdown()
|
||||
void Client::WritePrefs()
|
||||
{
|
||||
ClearThumbnailRequests();
|
||||
http_done();
|
||||
|
||||
//Save config
|
||||
std::ofstream configFile;
|
||||
configFile.open("powder.pref", std::ios::trunc);
|
||||
if(configFile)
|
||||
@ -708,6 +704,15 @@ void Client::Shutdown()
|
||||
}
|
||||
}
|
||||
|
||||
void Client::Shutdown()
|
||||
{
|
||||
ClearThumbnailRequests();
|
||||
http_done();
|
||||
|
||||
//Save config
|
||||
WritePrefs();
|
||||
}
|
||||
|
||||
Client::~Client()
|
||||
{
|
||||
}
|
||||
|
@ -141,6 +141,9 @@ public:
|
||||
void Tick();
|
||||
void Shutdown();
|
||||
|
||||
//Force flushing preferences to file on disk.
|
||||
void WritePrefs();
|
||||
|
||||
std::string GetPrefString(std::string property, std::string defaultValue);
|
||||
double GetPrefNumber(std::string property, double defaultValue);
|
||||
int GetPrefInteger(std::string property, int defaultValue);
|
||||
|
@ -105,13 +105,16 @@ private:
|
||||
notifyStatus("Applying update");
|
||||
notifyProgress(-1);
|
||||
|
||||
Client::Ref().SetPref("version.update", true);
|
||||
Client::Ref().WritePrefs();
|
||||
if (update_start(res, uncompressedLength))
|
||||
{
|
||||
Client::Ref().SetPref("version.update", false);
|
||||
update_cleanup();
|
||||
notifyError("Update failed - try downloading a new version.");
|
||||
return false;
|
||||
}
|
||||
|
||||
Client::Ref().SetPref("version.update", true);
|
||||
return true;
|
||||
|
||||
corrupt:
|
||||
|
Reference in New Issue
Block a user