Suppose to use the example CodeDownloadFiles.iss
and I would like to move downloaded files from the Temporary Download folder. Well, I tried to use the function OnDownloadProgress
but it seems that this code is performed before the download file effectively appears in the temp path:
procedure MoveTempFileDownloaded(FileName: String);
begin
FileCopy(ExpandConstant('{tmp}\' + FileName), ExpandConstant('{src}\storage\' + FileName), false);
DeleteFile(ExpandConstant('{tmp}\' + FileName));
end;
the upper procedure is that one should move the files (I have some heavy files) but when the following event will run, the current file will be the next one, so the file will be not copied.
function OnDownloadProgress(const Url, FileName: String; const Progress, ProgressMax: Int64): Boolean;
begin
if Progress = ProgressMax then
begin
MoveTempFileDownloaded(FileName);
end;
Result := True;
end;
In effect what I want to do is to store a list of Components files because if the user would reinstall the package will not need to re-download any files.
This is a sample of component that installer check before to run download:
FileName := 'MyDB1.sqlite';
ComponentIsSelected := CheckFileToDownload('https://example.com/MyFiles/'+FileName, FileName, 'Database\ABC');
if ComponentIsSelected = True then begin
DownloadPage.Add('https://example.com/MyFiles/'+FileName, FileName, '');
end;
at the beginning of the Inno file there is this function:
function CheckFileToDownload(const Url, FileName, ComponentName: String): Boolean;
begin
ComponentIsSelected := False;
if WizardIsComponentSelected(ComponentName) then begin
if FileExists(ExpandConstant('{src}\storage\'+FileName)) = False then begin
Inc(DownloadCount);
ComponentIsSelected := True;
end;
end;
end;
It will be easy in the [Files]
to copy temporary files but my files are heavy I would not to get disk space problems. How could I copy a single downloaded file while they are perfectly downloaded?
By the way, I should perform the selection of Components
with ExtraDiskSpaceRequired and get the size from the internet using DownloadTemporaryFileSize
to increase the Disk Required, but I still have to do it, before I would solve this issue.
By the way, do you think is more simple to find a way to change the temporary temp folder location of downloaded files or to try to move files as I'm doing?
Thanks in advance for any suggestions