예제 #1
0
        private void updateInteractionManager_UpdateAccepted(object sender, UpdateInfo update)
        {
            this.InvokeAsyncSafe(() => {
                FormManager.CloseAllDialogs();

                if (!string.IsNullOrEmpty(Config.DismissedUpdate))
                {
                    Config.DismissedUpdate = null;
                    Config.Save();
                }

                void OnFinished()
                {
                    UpdateDownloadStatus status = update.DownloadStatus;

                    if (status == UpdateDownloadStatus.Done)
                    {
                        UpdateInstaller = new UpdateInstaller(update.InstallerPath);
                        ForceClose();
                    }
                    else if (status != UpdateDownloadStatus.Canceled && FormMessage.Error("Update Has Failed", "Could not automatically download the update: " + (update.DownloadError?.Message ?? "unknown error") + "\n\nWould you like to open the website and try downloading the update manually?", FormMessage.Yes, FormMessage.No))
                    {
                        App.SystemHandler.OpenBrowser(Program.Website);
                        ForceClose();
                    }
                    else
                    {
                        Show();
                    }
                }

                if (update.DownloadStatus.IsFinished(true))
                {
                    OnFinished();
                }
                else
                {
                    FormUpdateDownload downloadForm = new FormUpdateDownload(update);

                    downloadForm.VisibleChanged += (sender2, args2) => {
                        downloadForm.MoveToCenter(this);
                        Hide();
                    };

                    downloadForm.FormClosed += (sender2, args2) => {
                        if (downloadForm.DialogResult != DialogResult.OK)
                        {
                            update.CancelDownload();
                        }

                        downloadForm.Dispose();
                        OnFinished();
                    };

                    downloadForm.Show();
                }
            });
        }
예제 #2
0
        public UpdateDownloadItem(UpdateTask updateTask, FileInfo downloadPath,
                                  Dictionary <UpdateSourceBase, UpdateItem> downloadSources)
        {
            DownloadSources = downloadSources ?? throw new ArgumentNullException(nameof(downloadSources));
            UpdateTask      = updateTask ?? throw new ArgumentNullException(nameof(updateTask));
            DownloadPath    = downloadPath ?? throw new ArgumentNullException(nameof(downloadPath));

            Status = UpdateDownloadStatus.Waiting;

            IsFileDelete = downloadSources.Any(x => x.Value is DeleteFileUpdateItem);
            TotalSize    = DownloadSources.FirstOrDefault().Value.GetDownloadSize();
        }
예제 #3
0
 public static bool IsFinished(this UpdateDownloadStatus status, bool canRetry)
 {
     return(status == UpdateDownloadStatus.AssetMissing || status == UpdateDownloadStatus.Done || (status == UpdateDownloadStatus.Failed && !canRetry));
 }