Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(windows): check the params status flag equals ucrsUpdateReady before attempting to download the keyman setup file #13154

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 22 additions & 23 deletions windows/src/desktop/kmshell/main/Keyman.System.DownloadUpdate.pas
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,12 @@ interface
KeymanPaths;

type
TDownloadUpdateParams = record
TotalSize: Integer;
TotalDownloads: Integer;
StartPosition: Integer;
end;


TDownloadUpdate = class
private
FShowErrors: Boolean;
FDownload: TDownloadUpdateParams;
FSuccessfulDownloadCount: Integer;
(**
*
* Performs updates download in the background.
Expand Down Expand Up @@ -135,35 +131,38 @@ function TDownloadUpdate.DoDownloadUpdates(SavePath: string; Params: TUpdateChec

begin
Result := False;

FDownload.TotalSize := 0;
FDownload.TotalDownloads := 0;

FSuccessfulDownloadCount := 0;
// Keyboard Packages
FDownload.StartPosition := 0;
for i := 0 to High(Params.Packages) do
begin
Inc(FDownload.TotalDownloads);
Inc(FDownload.TotalSize, Params.Packages[i].DownloadSize);
Params.Packages[i].SavePath := SavePath + Params.Packages[i].FileName;
if not DownloadFile(Params.Packages[i].DownloadURL, Params.Packages[i].SavePath) then // I2742
if DownloadFile(Params.Packages[i].DownloadURL, Params.Packages[i].SavePath) then
begin
Inc(FSuccessfulDownloadCount);
end
else
begin
Params.Packages[i].Install := False; // Download failed but install other files
end;
FDownload.StartPosition := FDownload.StartPosition + Params.Packages[i].DownloadSize;
end;

// Keyman Installer
Inc(FDownload.TotalDownloads);
Inc(FDownload.TotalSize, Params.InstallSize);
if not DownloadFile(Params.InstallURL, SavePath + Params.FileName) then // I2742
//
if Params.Status = ucrsUpdateReady then
begin
ErrorLogMessage('DoDownloadUpdates Failed to download' + Params.InstallURL);
end
else
if DownloadFile(Params.InstallURL, SavePath + Params.FileName) then
begin
Inc(FSuccessfulDownloadCount);
end
else
begin
ErrorLogMessage('DoDownloadUpdates Failed to download' + Params.InstallURL);
end;
end;
// If there is at least one keyboard package or version of keyman downloaded then
// the result is true
if (FSuccessfulDownloadCount > 0) then
begin
// If installer has downloaded that is success even
// if zero packages were downloaded.
Result := True;
end;
end;
Expand Down