0

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

  • 1
    Why don't you move all files at once after they are all downloaded? – Martin Prikryl Jun 14 '22 at 18:23
  • @MartinPrikryl because my files are heavy and 10 files are more than 1,5 GB. I think that the best is to move every single file but if it is too much tricky I'll follow your suggestion... by the way, I cleaned the code but my installer is using also the suggestions that you gave me someday ago – orecchione bruno Jun 14 '22 at 20:45
  • I do not see how does that explain my question. You will be moving 10 1,5GB files in either case. – Martin Prikryl Jun 15 '22 at 04:57
  • @MartinPrikryl opsss sorry for my error... yes it looks a good idea to move files at the end.. before I was copying files but yes I should move them instead to copy, ok thanksss – orecchione bruno Jun 15 '22 at 16:32
  • 1
    Note that you cannot expect to be able to move the files. You can move only within the same drive. So still should be able to fallback to copying, if moving is not possible. See also [Change download location for Inno Setup TDownloadWizardPage](https://stackoverflow.com/q/67992701/850848). – Martin Prikryl Jun 15 '22 at 18:27
  • @MartinPrikryl thank you, it's a very useful post ;D – orecchione bruno Jun 16 '22 at 16:38

0 Answers0