'Check if component was previously downloaded in Inno Setup
I don't know, if, what I'm asking for, it is possible, but anyway, here I go:
I have the following code that uses Inno Download Plugin:
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = wpReady then
begin
idpClearFiles;
if IsComponentSelected('src') then
begin
idpAddFile(
'https://example.com/files/prj-sources-1.2.3.zip',
ExpandConstant('{tmp}\src.zip'));
end;
end;
end;
and I would like to check, if the file is already downloaded in a folder before downloading it again, and if it is not, to download it.
Solution 1:[1]
You can check whether the file exists by the FileExists function. In your case it would be like:
procedure CurPageChanged(CurPageID: Integer);
var
FileName: string;
begin
if CurPageID = wpReady then
begin
idpClearFiles;
{ better use a local variable to avoid expanding the same path twice }
FileName := ExpandConstant('{tmp}\src.zip');
{ if the component item is checked and file does not exist yet, enqueue it }
if IsComponentSelected('src') and not FileExists(FileName) then
begin
idpAddFile(
'https://example.com/files/prj-sources-1.2.3.zip',
FileName);
end;
end;
end;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Martin Prikryl |
