1919#define ELIXIR_CSV_URL ' https://elixir-lang.org/elixir.csv'
2020#define ERLANG_CSV_URL ' https://elixir-lang.org/erlang.csv'
2121
22- #include <idp.iss>
23-
2422[Setup]
2523AppName = Elixir
2624AppVersion = 2.2
@@ -97,6 +95,7 @@ Name: "defer"; Description: "Defer installation (advanced)"; Flags: unchecked
9795
9896var
9997 GlobalPageSelRelease: TInputOptionWizardPage;
98+ GlobalPageDownload: TDownloadWizardPage;
10099
101100 GlobalElixirReleases: array of TElixirRelease;
102101 GlobalErlangData: TErlangData;
@@ -130,21 +129,6 @@ begin
130129
131130 if IsTaskSelected(' unins_previous' ) then
132131 ExecAsOriginalUser(GetPreviousUninsExe, ' /SILENT' , ' ' , SW_SHOW, ewWaitUntilTerminated, _int);
133-
134- with GlobalErlangData do begin
135- if IsTaskSelected(' erlang\32' ) then
136- // 32-bit OTP needs to be downloaded before it's installed
137- idpAddFile(URL32, Tmp(Exe32));
138- if IsTaskSelected(' erlang\64' ) then
139- // 64-bit OTP needs to be downloaded before it's installed
140- idpAddFile(URL64, Tmp(Exe64));
141- end ;
142-
143- // Download the Precompiled.zip archive for the selected release
144- idpAddFile(CacheSelectedRelease.URL, Tmp(' Precompiled.zip' ));
145-
146- // Put the downloader page directly after this page
147- idpDownloadAfter(wpPreparing);
148132 end ;
149133end ;
150134
@@ -155,14 +139,40 @@ var
155139begin
156140 Result := True;
157141
158- // Search for the selected release
159142 if CurPageID = GlobalPageSelRelease.ID then begin
143+ // Search for the selected release
160144 for i := 0 to GlobalPageSelRelease.CheckListBox.Items.Count - 1 do begin
161145 if GlobalPageSelRelease.CheckListBox.Checked[i] then begin
162146 CacheSelectedRelease := GlobalElixirReleases[i];
163147 break;
164148 end ;
165149 end ;
150+ end else if CurPageID = wpReady then begin
151+ GlobalPageDownload.Clear;
152+ with GlobalErlangData do begin
153+ if IsTaskSelected(' erlang\32' ) then
154+ // 32-bit OTP needs to be downloaded before it's installed
155+ GlobalPageDownload.Add(URL32, Exe32, ' ' );
156+ if IsTaskSelected(' erlang\64' ) then
157+ // 64-bit OTP needs to be downloaded before it's installed
158+ GlobalPageDownload.Add(URL64, Exe64, ' ' );
159+ end ;
160+
161+ // Download the Precompiled.zip archive for the selected release
162+ GlobalPageDownload.Add(CacheSelectedRelease.URL, ' Precompiled.zip' , ' ' );
163+
164+ // Run page
165+ GlobalPageDownload.Show;
166+ try
167+ try
168+ GlobalPageDownload.Download;
169+ except
170+ MsgBox(GetExceptionMessage, mbCriticalError, MB_OK);
171+ Result := False;
172+ end
173+ finally
174+ GlobalPageDownload.Hide;
175+ end ;
166176 end ;
167177end ;
168178
@@ -198,6 +208,8 @@ begin
198208 latest := False;
199209 end
200210 end ;
211+
212+ GlobalPageDownload := CreateDownloadPage(SetupMessage(msgWizardPreparing), SetupMessage(msgPreparingDesc), Nil );
201213end ;
202214
203215function InitializeSetup (): Boolean;
@@ -209,14 +221,18 @@ begin
209221 GlobalErlangCSVFilePath := Tmp(GetURLFilePart(' {#ERLANG_CSV_URL}' ));
210222
211223 // Download elixir.csv; show an error message and exit the installer if downloading fails
212- if not idpDownloadFile(' {#ELIXIR_CSV_URL}' , GlobalElixirCSVFilePath) then begin
213- MsgBox(' Error: Downloading {#ELIXIR_CSV_URL} failed. Setup cannot continue.' , mbInformation, MB_OK);
224+ try
225+ DownloadTemporaryFile(' {#ELIXIR_CSV_URL}' , GetURLFilePart(' {#ELIXIR_CSV_URL}' ), ' ' , Nil );
226+ except
227+ MsgBox(' {#ELIXIR_CSV_URL} - ' + GetExceptionMessage + ' . Setup cannot continue.' , mbInformation, MB_OK);
214228 Result := False;
215229 exit;
216230 end ;
217231 // Download erlang.csv; show an error message and exit the installer if downloading fails
218- if not idpDownloadFile(' {#ERLANG_CSV_URL}' , GlobalErlangCSVFilePath) then begin
219- MsgBox(' Error: Downloading {#ERLANG_CSV_URL} failed. Setup cannot continue.' , mbInformation, MB_OK);
232+ try
233+ DownloadTemporaryFile(' {#ERLANG_CSV_URL}' , GetURLFilePart(' {#ERLANG_CSV_URL}' ), ' ' , Nil );
234+ except
235+ MsgBox(' {#ERLANG_CSV_URL} - ' + GetExceptionMessage + ' . Setup cannot continue.' , mbInformation, MB_OK);
220236 Result := False;
221237 exit;
222238 end ;
0 commit comments