CreateDownloadPage issue without content-length header

551 views
Skip to first unread message

Louis Vézina

unread,
Mar 14, 2021, 11:55:08 AM3/14/21
to innosetup
Hi everyone,

I'm just trying the new CreateDownloadPage function in 6.1.2 but I face an issue when trying to download a zip file from Github. They do not return the content-length header so Inno Setup is reporting -1. That fine until the download ends and throw this exception: `Exception: Invalid progress: 12316250 of -1`.

Is there anything I'm missing here? Anyway to prevent Inno from validating the size?

Here's my test case:
```
; -- CodeDownloadFiles.iss --
;
; This script shows how the CreateDownloadPage support function can be used to
; download temporary files while showing the download progress to the user.

[Setup]
AppName=My Program
AppVersion=1.5
WizardStyle=modern
DefaultDirName={autopf}\My Program
DefaultGroupName=My Program
UninstallDisplayIcon={app}\MyProg.exe
OutputDir=userdocs:Inno Setup Examples Output

[Files]
; Place any regular files here
//Source: "MyProg.exe"; DestDir: "{app}";
//Source: "MyProg.chm"; DestDir: "{app}";
//Source: "Readme.txt"; DestDir: "{app}"; Flags: isreadme;
; These files will be downloaded
Source: "{tmp}\bazarr.zip"; DestDir: "{app}"; Flags: external

[Icons]
Name: "{group}\My Program"; Filename: "{app}\MyProg.exe"

[Code]
var
  DownloadPage: TDownloadWizardPage;

function OnDownloadProgress(const Url, FileName: String; const Progress, ProgressMax: Int64): Boolean;
begin
  if Progress = ProgressMax then
    Log(Format('Successfully downloaded file to {tmp}: %s', [FileName]));
  Result := True;
end;

procedure InitializeWizard;
begin
  DownloadPage := CreateDownloadPage(SetupMessage(msgWizardPreparing), SetupMessage(msgPreparingDesc), @OnDownloadProgress);
end;

function NextButtonClick(CurPageID: Integer): Boolean;
begin
  if CurPageID = wpReady then begin
    DownloadPage.Clear;
    DownloadPage.Add('https://github.com/PowerShell/PowerShell/archive/master.zip', 'master.zip', '');
    DownloadPage.Show;
    try
      try
        DownloadPage.Download;
        Result := True;
      except
        SuppressibleMsgBox(AddPeriod(GetExceptionMessage), mbCriticalError, MB_OK, IDOK);
        Result := False;
      end;
    finally
      DownloadPage.Hide;
    end;
  end else
    Result := True;
end;
```

Martijn Laan

unread,
Mar 16, 2021, 12:22:37 PM3/16/21
to inno...@googlegroups.com
Op 14-3-2021 om 16:55 schreef Louis Vézina:
Anyway to prevent Inno from validating the size?

Use the third parameter to tell it the expected SHA256 hash and then it won't check the size because it checks the hash instead.

Greetings,
Martijn

Louis Vézina

unread,
Mar 18, 2021, 6:31:31 AM3/18/21
to innosetup
Thanks for the answer. Unfortunately, as the file will get updated over time (in fact each time a new version is released), I can't specify the hash. Any other idea? Are you able to reproduce the issue?

Martijn Laan

unread,
Mar 20, 2021, 10:06:37 AM3/20/21
to inno...@googlegroups.com
Op 18-3-2021 om 11:31 schreef Louis Vézina:
Thanks for the answer. Unfortunately, as the file will get updated over time (in fact each time a new version is released), I can't specify the hash. Any other idea? Are you able to reproduce the issue?

Yes I can, but on the other hand it seems a bit odd / unsafe for an installer to allow the download of a file you basically know nothing about. IS is pretty paranoid about checkng the downloaded file for a reason.

Why are you downloading it as part of the install instead of by your application? How do you keep it up to date since it's an unstable file?

Greetings,
Martijn

Louis Vézina

unread,
Mar 20, 2021, 10:34:58 PM3/20/21
to innosetup
I want to create an base installer (which will include WinPython and nssm) that will download the latest Github release of my python script. Currently I include the content of the Github release zip inside my installer but it means I have to update the installer from time to time and I would prefer to put my time into improving my program instead of packaging it over and over again. As I'm controlling the release process over Github, it doesn't sound unsafe to me. Thanks for your help BTW!

Martijn Laan

unread,
Mar 21, 2021, 9:46:00 AM3/21/21
to inno...@googlegroups.com
Op 21-3-2021 om 03:34 schreef Louis Vézina:
I want to create an base installer (which will include WinPython and nssm) that will download the latest Github release of my python script. Currently I include the content of the Github release zip inside my installer but it means I have to update the installer from time to time and I would prefer to put my time into improving my program instead of packaging it over and over again. As I'm controlling the release process over Github, it doesn't sound unsafe to me. Thanks for your help BTW!

Ok, in the next version the built-in download support allows the download of files for which the server does not specify the file size.

Greetings,
Martijn

Louis Vézina

unread,
Mar 21, 2021, 9:53:16 AM3/21/21
to innosetup

Thanks, that's appreciated!

Louis Vézina

unread,
Mar 21, 2021, 10:00:53 AM3/21/21
to innosetup
Any ETA for 6.1.3?
Reply all
Reply to author
Forward
0 new messages