Skip to content

Commit

Permalink
feat(windows): More formatting fixes.
Browse files Browse the repository at this point in the history
Co-authored-by: Marc Durdin <[email protected]>
  • Loading branch information
rc-swag and mcdurdin authored Oct 15, 2024
1 parent c988271 commit ac38649
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,19 @@
interface

uses

Windows,
Messages,
SysUtils,
Variants,
Classes,
Graphics,
Controls,
Forms,
Dialogs,
UserMessages,
StdCtrls,
ExtCtrls,
UfrmKeymanBase;
System.Classes,
System.SysUtils,
System.Variants,
Vcl.Controls,
Vcl.Dialogs,
Vcl.ExtCtrls,
Vcl.Forms,
Vcl.Graphics,
Vcl.StdCtrls,
Winapi.Messages,
Winapi.Windows,
UfrmKeymanBase,
UserMessages;

type
TfrmStartInstall = class(TfrmKeymanBase)
Expand Down
66 changes: 25 additions & 41 deletions windows/src/desktop/kmshell/main/Keyman.System.DownloadUpdate.pas
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
(*
Name: WebUpdateCheck
Copyright: Copyright (C) SIL Global.
Documentation:
Description:
Create Date: 5 Dec 2023
Modified Date:
Authors: rcruickshank
Related Files:
Dependencies:
Bugs:
Todo:
Notes:
History:
*)

* Keyman is copyright (C) SIL Global. MIT License.
*)
unit Keyman.System.DownloadUpdate;

interface
Expand All @@ -28,7 +13,7 @@ interface
OnlineUpdateCheck;

const
CheckPeriod: Integer = 7; // Days between checking for updates
DaysBetweenCheckingForUpdates: Integer = 7; // Days between checking for updates

type
TDownloadUpdateParams = record
Expand Down Expand Up @@ -88,7 +73,7 @@ implementation
System.Types,
System.StrUtils;

// temp wrapper for converting showmessage to logs don't know where
// TODO-WINDOWS-UPDATES: temp wrapper for converting showmessage to logs don't know where
// if not using klog
procedure LogMessage(LogMessage: string);
begin
Expand Down Expand Up @@ -142,9 +127,10 @@ procedure TDownloadUpdate.DoDownloadUpdates(SavePath: string; Params: TUpdateChe
Result := True;
end
else // I2742
begin
// If it fails we set to false but will try the other files
Result := False;
Exit;
Exit(False);
end;
finally
http.Free;
end;
Expand Down Expand Up @@ -181,20 +167,20 @@ procedure TDownloadUpdate.DoDownloadUpdates(SavePath: string; Params: TUpdateChe
// Keyboard Packages
FDownload.StartPosition := 0;
for i := 0 to High(Params.Packages) do
begin
if not DownloadFile(Params.Packages[i].DownloadURL, Params.Packages[i].SavePath) then // I2742
begin
if not DownloadFile(Params.Packages[i].DownloadURL, Params.Packages[i].SavePath) then // I2742
begin
Params.Packages[i].Install := False; // Download failed but install other files
end
else
Inc(downloadCount);
FDownload.StartPosition := FDownload.StartPosition + Params.Packages[i].DownloadSize;
end;
Params.Packages[i].Install := False; // Download failed but install other files
end
else
Inc(downloadCount);
FDownload.StartPosition := FDownload.StartPosition + Params.Packages[i].DownloadSize;
end;

// Keyman Installer
if not DownloadFile(Params.InstallURL, SavePath + Params.FileName) then // I2742
begin
// TODO: #10210 convert to error log.
// TODO-WINDOWS-UPDATES: #10210 convert to error log.
LogMessage('DoDownloadUpdates Failed to download' + Params.InstallURL);
end
else
Expand Down Expand Up @@ -249,23 +235,21 @@ function TDownloadUpdate.CheckAllFilesDownloaded: Boolean;
begin
Inc(VerifyDownloads.TotalDownloads);
Inc(VerifyDownloads.TotalSize, Params.Packages[i].DownloadSize);
if Not MatchStr(Params.Packages[i].FileName, FileNames) then
begin
Result := False;
Exit;
end;
if not MatchStr(Params.Packages[i].FileName, FileNames) then
begin
Exit(False);
end;
Params.Packages[i].SavePath := SavedPath + Params.Packages[i].FileName;
end;
// Add the Keyman installer
Inc(FDownload.TotalDownloads);
Inc(FDownload.TotalSize, Params.InstallSize);
// Check if the Keyman installer downloaded
if Not MatchStr(Params.FileName, FileNames) then
begin
Result := False;
Exit;
end;
// TODO verify filesizes match so we know we don't have partial downloades.
if not MatchStr(Params.FileName, FileNames) then
begin
Exit(False);
end;
// TODO-WINDOWS-UPDATES: verify filesizes match so we know we don't have partial downloades.
Result := True;
end
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,18 +231,12 @@ function ConfigCheckContinue: Boolean;
begin
if registry.ValueExists(SRegValue_CheckForUpdates) and not registry.ReadBool(SRegValue_CheckForUpdates) then
begin
Result := False;
Exit;
end;
if registry.ValueExists(SRegValue_LastUpdateCheckTime) and (Now - registry.ReadDateTime(SRegValue_LastUpdateCheckTime) > CheckPeriod) then
begin
Result := True;
end
else
begin
Result := False;
end;
Exit;
end;
finally
registry.Free;
Expand All @@ -253,7 +247,6 @@ function ConfigCheckContinue: Boolean;
begin
Result := False;
LogMessage(E.Message);
Exit;
end;
end;
end;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function EnginePostInstall(hInstall: MSIHANDLE): UINT;
end;

Result := ERROR_SUCCESS;
// TODO better error checking on the registry key update
// TODO-WINDOWS-UPDATES: better error checking on the registry key update
UpdateState;

finally
Expand Down

0 comments on commit ac38649

Please sign in to comment.