Skip to content

Commit

Permalink
Increase timeout, display versions, auto-proxy fix
Browse files Browse the repository at this point in the history
Timeout is now 90 seconds for both connection and transfer. Versions are displayed before installing. Getting the version respects the OS proxy settings.
  • Loading branch information
GeKorm committed Nov 5, 2017
1 parent 7aef0d3 commit 443037d
Show file tree
Hide file tree
Showing 4 changed files with 244 additions and 41 deletions.
63 changes: 61 additions & 2 deletions dart_x64_dev_setup.iss
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}\dart-sdk\bin"; Check: NeedsAddPath('{app}\dart-sdk\bin')
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: expandsz; ValueName: "DART_SDK"; ValueData: "{app}\dart-sdk";

[CustomMessages]
DartLatestVersion=The latest dev version will be installed: %1

[Code]
// SO: http://stackoverflow.com/questions/3304463/
function NeedsAddPath(Param: string): Boolean;
var
OrigPath: string;
Expand All @@ -85,10 +87,31 @@ begin
Result := Pos(';' + UpperCase(ParamExpanded) + '\;', ';' + UpperCase(OrigPath) + ';') = 0;
end;
// Internet latest version
function GetCurVersion(Param: string): string;
var
FormattedRevision: string;
Index: Integer;
begin
FormattedRevision := Param;
Index := Pos('version', Param);
Index := Index +11;
Delete(FormattedRevision, 1, Index - 1);
Index := Pos('"', FormattedRevision);
Delete(FormattedRevision, Index, 4);
Index := Pos('"', FormattedRevision);
Delete(FormattedRevision, Index, 400);
Result := FormattedRevision;
Exit;
end;
procedure InitializeWizard;
begin
// Only tell the plugin when we want to start downloading
// Add the files to the list; at this time, the {app} directory is known
idpSetOption('ConnectTimeout', '90000');
idpSetOption('SendTimeout', '90000');
idpSetOption('ReceiveTimeout', '90000');
idpAddFile('https://storage.googleapis.com/dart-archive/channels/dev/release/latest/dartium/dartium-windows-ia32-release.zip', ExpandConstant('{tmp}\dartium.zip'));
idpAddFile('https://storage.googleapis.com/dart-archive/channels/dev/release/latest/sdk/dartsdk-windows-x64-release.zip', ExpandConstant('{tmp}\dart-sdk.zip'));
idpDownloadAfter(wpReady);
Expand Down Expand Up @@ -161,8 +184,44 @@ end;
procedure CurPageChanged(CurPageID: Integer);
var
S: string;
SilUpdate: string;
CurrentVersion: string;
Page: TWizardPage;
LatestLabel: TNewStaticText;
begin
// If the user just reached the ready page, then...
// If the user just reached the installing page, then...
if CurPageID = wpInstalling then
begin
// Extract 7za to temp folder
ExtractTemporaryFile('7za.exe');
// Extract the zip to the temp folder (when included in the installer)
// Skip this, when the file is downloaded with IDP to the temp folder
// ExtractTemporaryFile('app.zip);
// Unzip the Dart SDK zip in the tempfolder to your temp target path
DoUnzip(ExpandConstant('{tmp}\') + 'dart-sdk.zip', ExpandConstant('{tmp}'));
// Unzip the Dartium zip in the tempfolder to your temp target path
DoUnzip(ExpandConstant('{tmp}\') + 'dartium.zip', ExpandConstant('{tmp}\temp-dartium'));
end;
// If the user just reached the Ready page, then...
if CurPageID = wpReady then
begin
// Download VERSION text file
if idpDownloadFile('https://storage.googleapis.com/dart-archive/channels/dev/release/latest/VERSION', ExpandConstant('{tmp}\VERSION.txt')) then
begin
// Version fetched
// Read the file
LoadStringFromFile(ExpandConstant('{tmp}\VERSION.txt'), SilUpdate);
CurrentVersion := GetCurVersion(SilUpdate);
Page := PageFromID(wpReady);
LatestLabel := TNewStaticText.Create(WizardForm);
LatestLabel.Parent := Page.Surface;
LatestLabel.Caption := FmtMessage(CustomMessage('DartLatestVersion'), [CurrentVersion]);
WizardForm.ReadyLabel.Top := LatestLabel.Top + WizardForm.ReadyLabel.Height + 16;
end
end;
// If the user just reached the Installing page, then...
if CurPageID = wpInstalling then
begin
// Extract 7za to temp folder
Expand Down
80 changes: 61 additions & 19 deletions dart_x64_dev_update.iss
Original file line number Diff line number Diff line change
Expand Up @@ -71,25 +71,11 @@ SetupWindowTitle = Update {#MyAppName}
ExitSetupTitle = Exit Update
ExitSetupMessage = Update is not complete. If you exit now, Dart will not be updated.%n%nYou may run Dart Update again at another time to complete the installation.%n%nExit Update?

[Code]
// Download text file
function DownloadTextFile(const AURL: string; var AResponse: string): Boolean;
var
WinHttpRequest: Variant;
begin
Result := TRUE;
try
WinHttpRequest := CreateOleObject('WinHttp.WinHttpRequest.5.1');
WinHttpRequest.Open('GET', AURL, FALSE);
WinHttpRequest.Send;
AResponse := WinHttpRequest.ResponseText;
except
Result := FALSE;
AResponse := GetExceptionMessage;
end;
end;
[CustomMessages]
DartInstalledVersion=Installed version: %1
DartLatestVersion=Latest (dev) version: %1

[Code]
// SO: http://stackoverflow.com/questions/3304463/
function NeedsAddPath(Param: string): Boolean;
var
Expand All @@ -110,6 +96,7 @@ begin
Result := Pos(';' + UpperCase(ParamExpanded) + '\;', ';' + UpperCase(OrigPath) + ';') = 0;
end;
// Internet latest revision
function GetCurRevision(Param: string): string;
var
FormattedRevision: string;
Expand All @@ -125,6 +112,7 @@ begin
Exit;
end;
// Installed revision
function GetInsRevision(PathToApp: string): string;
var
FormattedRevision: string;
Expand All @@ -137,10 +125,44 @@ begin
Result := FormattedRevision;
end;
// Internet latest version
function GetCurVersion(Param: string): string;
var
FormattedRevision: string;
Index: Integer;
begin
FormattedRevision := Param;
Index := Pos('version', Param);
Index := Index +11;
Delete(FormattedRevision, 1, Index - 1);
Index := Pos('"', FormattedRevision);
Delete(FormattedRevision, Index, 4);
Index := Pos('"', FormattedRevision);
Delete(FormattedRevision, Index, 400);
Result := FormattedRevision;
Exit;
end;
// Installed version
function GetInsVersion(PathToApp: string): string;
var
FormattedRevision: string;
Index: Integer;
RevisionFile: string;
begin
LoadStringFromFile(PathToApp + 'dart-sdk\version', FormattedRevision);
FormattedRevision := Trim(FormattedRevision);
Log('The final Ins Ver is: ' + FormattedRevision);
Result := FormattedRevision;
end;
procedure InitializeWizard;
begin
// Only tell the plugin when we want to start downloading
// Add the files to the list; at this time, the {app} directory is known
idpSetOption('ConnectTimeout', '90000');
idpSetOption('SendTimeout', '90000');
idpSetOption('ReceiveTimeout', '90000');
idpAddFile('https://storage.googleapis.com/dart-archive/channels/dev/release/latest/dartium/dartium-windows-ia32-release.zip', ExpandConstant('{tmp}\dartium.zip'));
idpAddFile('https://storage.googleapis.com/dart-archive/channels/dev/release/latest/sdk/dartsdk-windows-x64-release.zip', ExpandConstant('{tmp}\dart-sdk.zip'));
idpDownloadAfter(wpReady);
Expand Down Expand Up @@ -213,24 +235,44 @@ var
SilUpdate: string;
Current: string;
Installed: string;
CurrentVersion: string;
InstalledVersion: string;
S: string;
Page: TWizardPage;
InstalledLabel: TNewStaticText;
LatestLabel: TNewStaticText;
begin
// If the user just reached the Ready page, then...
if CurPageID = wpReady then
begin
if DownloadTextFile('https://storage.googleapis.com/dart-archive/channels/dev/release/latest/VERSION', SilUpdate) then
// Download VERSION text file
if idpDownloadFile('https://storage.googleapis.com/dart-archive/channels/dev/release/latest/VERSION', ExpandConstant('{tmp}\VERSION.txt')) then
begin
// Version fetched
// Read the file and transform the String to: int.int.int. ... .int
LoadStringFromFile(ExpandConstant('{tmp}\VERSION.txt'), SilUpdate);
Current := GetCurRevision(SilUpdate);
Installed := GetInsRevision(ExpandConstant('{app}\'));
CurrentVersion := GetCurVersion(SilUpdate);
InstalledVersion := GetInsVersion(ExpandConstant('{app}\'));
if (Installed = Current) then
begin
// Dart is up to date
MsgBox('Dart is up to date!', mbInformation, MB_OK);
WizardForm.Close;
end
else
begin
Page := PageFromID(wpReady);
InstalledLabel := TNewStaticText.Create(WizardForm);
InstalledLabel.Parent := Page.Surface;
InstalledLabel.Caption := FmtMessage(CustomMessage('DartInstalledVersion'), [InstalledVersion]);
LatestLabel := TNewStaticText.Create(WizardForm);
LatestLabel.Parent := Page.Surface;
LatestLabel.Caption := FmtMessage(CustomMessage('DartLatestVersion'), [CurrentVersion]);
LatestLabel.Top := InstalledLabel.Top + LatestLabel.Height + 4;
WizardForm.ReadyLabel.Top := LatestLabel.Top + WizardForm.ReadyLabel.Height + 16;
end
end
else
// Failed to fetch resource
Expand Down
62 changes: 61 additions & 1 deletion dart_x64_stable_setup.iss
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}\dart-sdk\bin"; Check: NeedsAddPath('{app}\dart-sdk\bin')
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: expandsz; ValueName: "DART_SDK"; ValueData: "{app}\dart-sdk";

[CustomMessages]
DartLatestVersion=The latest stable version will be installed: %1

[Code]
// SO: http://stackoverflow.com/questions/3304463/
Expand All @@ -85,10 +88,31 @@ begin
Result := Pos(';' + UpperCase(ParamExpanded) + '\;', ';' + UpperCase(OrigPath) + ';') = 0;
end;
// Internet latest version
function GetCurVersion(Param: string): string;
var
FormattedRevision: string;
Index: Integer;
begin
FormattedRevision := Param;
Index := Pos('version', Param);
Index := Index +11;
Delete(FormattedRevision, 1, Index - 1);
Index := Pos('"', FormattedRevision);
Delete(FormattedRevision, Index, 4);
Index := Pos('"', FormattedRevision);
Delete(FormattedRevision, Index, 400);
Result := FormattedRevision;
Exit;
end;
procedure InitializeWizard;
begin
// Only tell the plugin when we want to start downloading
// Add the files to the list; at this time, the {app} directory is known
idpSetOption('ConnectTimeout', '90000');
idpSetOption('SendTimeout', '90000');
idpSetOption('ReceiveTimeout', '90000');
idpAddFile('https://storage.googleapis.com/dart-archive/channels/stable/release/latest/dartium/dartium-windows-ia32-release.zip', ExpandConstant('{tmp}\dartium.zip'));
idpAddFile('https://storage.googleapis.com/dart-archive/channels/stable/release/latest/sdk/dartsdk-windows-x64-release.zip', ExpandConstant('{tmp}\dart-sdk.zip'));
idpDownloadAfter(wpReady);
Expand Down Expand Up @@ -161,8 +185,44 @@ end;
procedure CurPageChanged(CurPageID: Integer);
var
S: string;
SilUpdate: string;
CurrentVersion: string;
Page: TWizardPage;
LatestLabel: TNewStaticText;
begin
// If the user just reached the ready page, then...
// If the user just reached the installing page, then...
if CurPageID = wpInstalling then
begin
// Extract 7za to temp folder
ExtractTemporaryFile('7za.exe');
// Extract the zip to the temp folder (when included in the installer)
// Skip this, when the file is downloaded with IDP to the temp folder
// ExtractTemporaryFile('app.zip);
// Unzip the Dart SDK zip in the tempfolder to your temp target path
DoUnzip(ExpandConstant('{tmp}\') + 'dart-sdk.zip', ExpandConstant('{tmp}'));
// Unzip the Dartium zip in the tempfolder to your temp target path
DoUnzip(ExpandConstant('{tmp}\') + 'dartium.zip', ExpandConstant('{tmp}\temp-dartium'));
end;
// If the user just reached the Ready page, then...
if CurPageID = wpReady then
begin
// Download VERSION text file
if idpDownloadFile('https://storage.googleapis.com/dart-archive/channels/stable/release/latest/VERSION', ExpandConstant('{tmp}\VERSION.txt')) then
begin
// Version fetched
// Read the file
LoadStringFromFile(ExpandConstant('{tmp}\VERSION.txt'), SilUpdate);
CurrentVersion := GetCurVersion(SilUpdate);
Page := PageFromID(wpReady);
LatestLabel := TNewStaticText.Create(WizardForm);
LatestLabel.Parent := Page.Surface;
LatestLabel.Caption := FmtMessage(CustomMessage('DartLatestVersion'), [CurrentVersion]);
WizardForm.ReadyLabel.Top := LatestLabel.Top + WizardForm.ReadyLabel.Height + 16;
end
end;
// If the user just reached the Installing page, then...
if CurPageID = wpInstalling then
begin
// Extract 7za to temp folder
Expand Down
Loading

0 comments on commit 443037d

Please sign in to comment.