浏览代码

WIP: add retry question + add note how to make it work better.

Martijn Laan 3 月之前
父节点
当前提交
02a6880a0e
共有 1 个文件被更改,包括 23 次插入1 次删除
  1. 23 1
      Projects/Src/Setup.WizardForm.pas

+ 23 - 1
Projects/Src/Setup.WizardForm.pas

@@ -1844,6 +1844,16 @@ function TWizardForm.PrepareToInstall(const WizardComponents, WizardTasks: TStri
     end;
   end;
 
+  function AskRetryDownloadArchivesToExtract(const Failed: String): Integer;
+  begin
+    {!!!} //make this a proper message - also see RenameUninstallExe which has a retrycancel msgbox as well
+    Result := LoggedMsgBox(Failed + SNewLine2 + 'Retry?', '', mbConfirmation, MB_RETRYCANCEL, True, IDCANCEL);
+    if (Result <> IDRETRY) and (Result <> IDCANCEL) then begin
+      Log('LoggedMsgBox returned an unexpected value. Assuming Cancel.');
+      Result := IDCANCEL;
+    end;
+  end;
+
   procedure DownloadArchivesToExtract;
   begin
     var DownloadPage: TDownloadWizardPage := nil;
@@ -1886,9 +1896,21 @@ function TWizardForm.PrepareToInstall(const WizardComponents, WizardTasks: TStri
       if DownloadPage <> nil then begin
         DownloadPage.Show;
         try
-          DownloadPage.Download;
+          var Failed: String;
+          repeat
+            Failed := '';
+            try
+              DownloadPage.Download;  { Does not throw EAbort }
+            except
+              Failed := GetExceptMessage;
+            end;
+          until (Failed = '') or (AskRetryDownloadArchivesToExtract(Failed) = IDCANCEL);
+          if Failed <> '' then
+            raise Exception.Create(Failed);
+
           for var A in ArchivesToDownload do begin
             with PSetupFileEntry(Entries[seFile][A.Key])^ do begin
+              {!!!} //make it do this per file immediately after file's download success - so that on retries it skips files which succeeded
               SourceFilename := A.Value;
               { Remove Download flag since download has been done, and remove CustomDestName flag
                 since ExtractArchive flag doesn't like that }