mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2026-03-13 09:24:25 +08:00
Issue #1616: force update check to overwrite old HeidiSQL_update.exe in temp directory, once through different file size, and by logic when old one is older than 30 days. Fixes still used old updater with bugs.
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
brcc32 res\version.rc
|
||||
cgrc res\icon.rc
|
||||
brcc32 res\icon-question.rc
|
||||
brcc32 res\manifest.rc
|
||||
brcc32 -fores\updater.res res\updater32.rc
|
||||
cgrc.exe res\styles.rc
|
||||
pause
|
||||
brcc32 res\version.rc
|
||||
cgrc res\icon.rc
|
||||
brcc32 res\icon-question.rc
|
||||
brcc32 res\manifest.rc
|
||||
brcc32 -fores\updater.res res\updater64.rc
|
||||
cgrc.exe res\styles.rc
|
||||
brcc32.exe source\vcl-styles-utils\AwesomeFont.rc
|
||||
brcc32.exe source\vcl-styles-utils\AwesomeFont_zip.rc
|
||||
pause
|
||||
|
||||
@@ -5,6 +5,9 @@ program updater;
|
||||
|
||||
{$R manifest.RES}
|
||||
|
||||
// (un)comment the following resource inclusion to vary the binary size. Update checker trusts the same file size before overwriting the old one.
|
||||
{$R ..\icon.RES}
|
||||
|
||||
uses
|
||||
Windows, Messages, Tlhelp32, psapi;
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -5,7 +5,7 @@ interface
|
||||
uses
|
||||
Windows, Messages, SysUtils, Classes, Forms, StdCtrls, IniFiles, Controls, Graphics,
|
||||
apphelpers, gnugettext, ExtCtrls, extra_controls, System.StrUtils, Vcl.Dialogs,
|
||||
Vcl.Menus, Vcl.Clipbrd, generic_types;
|
||||
Vcl.Menus, Vcl.Clipbrd, generic_types, System.DateUtils;
|
||||
|
||||
type
|
||||
TfrmUpdateCheck = class(TExtForm)
|
||||
@@ -255,6 +255,8 @@ var
|
||||
ResPointer: PChar;
|
||||
Stream: TMemoryStream;
|
||||
BuildSizeDownloaded: Int64;
|
||||
DoOverwrite: Boolean;
|
||||
UpdaterAge: TDateTime;
|
||||
begin
|
||||
Download := THttpDownload.Create(Self);
|
||||
Download.URL := BuildURL;
|
||||
@@ -289,11 +291,20 @@ begin
|
||||
Stream.WriteBuffer(ResPointer[0], SizeOfResource(HInstance, ResInfoblockHandle));
|
||||
Stream.Position := 0;
|
||||
UpdaterFilename := GetTempDir + AppName+'_updater.exe';
|
||||
if FileExists(UpdaterFilename) and (Stream.Size = _GetFileSize(UpdaterFilename)) then
|
||||
|
||||
DoOverwrite := True;
|
||||
if FileExists(UpdaterFilename) and (Stream.Size = _GetFileSize(UpdaterFilename)) then begin
|
||||
// Do not replace old updater if it's still valid. Avoids annoyance for cases in which
|
||||
// user has whitelisted this .exe in his antivirus or whatever software.
|
||||
else
|
||||
FileAge(UpdaterFilename, UpdaterAge);
|
||||
if Abs(DaysBetween(Now, UpdaterAge)) < 30 then
|
||||
DoOverwrite := False;
|
||||
end;
|
||||
|
||||
if DoOverwrite then begin
|
||||
Stream.SaveToFile(UpdaterFilename);
|
||||
end;
|
||||
|
||||
// Calling the script will now post a WM_CLOSE this running exe...
|
||||
ShellExec(UpdaterFilename, '', '"'+ParamStr(0)+'" "'+DownloadFilename+'"');
|
||||
finally
|
||||
|
||||
Reference in New Issue
Block a user