/// <summary> /// Called when a new release has been downloaded /// </summary> protected virtual void OnNewReleaseDownloaded(GitHubUpdater gitHubUpdater, string downloadedFile) { try { // Extract the .zip file if (Utils.ExtractAll(downloadedFile, FolderUnzip)) { // execute extra actions (for the 3P update for instance) if (ExtraActionWhenDownloaded != null) { ExtraActionWhenDownloaded(gitHubUpdater); } NotifyUpdateAvailable(Updater); if (gitHubUpdater.LatestReleaseInfo != null && !RestartNeeded) { Updater.LocalVersion = gitHubUpdater.LatestReleaseInfo.tag_name; } if (OnUpdateDone != null) { OnUpdateDone(this); } } else { UserCommunication.NotifyUnique("Update" + UpdatedSoftName, "Failed to unzip the following file : <br>" + downloadedFile.ToHtmlLink() + "<br>It contains the update for " + UpdatedSoftName + ", you will have to do a manual update." + HowToInstallManually, MessageImg.MsgError, UpdatedSoftName + " updater", "Unzip failed", null); } } finally { _updating = false; } }
/// <summary> /// Called when the latest release download is done /// </summary> /// <param name="sender"></param> /// <param name="asyncCompletedEventArgs"></param> private static void OnDownloadFileCompleted(object sender, AsyncCompletedEventArgs asyncCompletedEventArgs) { try { // Extract the .zip file if (Utils.ExtractAll(Config.FileLatestReleaseZip, Config.FolderUpdate)) { // check the presence of the plugin file if (File.Exists(Config.FileDownloadedPlugin)) { // set up the update so the .dll file downloaded replaces the current .dll _3PUpdater.Instance.AddFileToMove(Config.FileDownloadedPlugin, AssemblyInfo.Location); // if the release was containing a .pdb file, we want to copied it as well if (File.Exists(Config.FileDownloadedPdb)) { _3PUpdater.Instance.AddFileToMove(Config.FileDownloadedPdb, Path.Combine(Path.GetDirectoryName(AssemblyInfo.Location) ?? "", Path.GetFileName(Config.FileDownloadedPdb) ?? "")); } // write the version log Utils.FileWriteAllText(Config.FileVersionLog, _latestReleaseInfo.body, Encoding.Default); Utils.FileWriteAllText(Config.FilePreviousVersion, AssemblyInfo.Version, Encoding.Default); NotifyUpdateAvailable(); } else { Utils.DeleteDirectory(Config.FolderUpdate, true); } } else { UserCommunication.Notify("I failed to unzip the following file : <br>" + Config.FileLatestReleaseZip + "<br>It contains the update for 3P, you will have to do a manual update.", MessageImg.MsgError, "Unzip", "Failed"); } } catch (Exception e) { ErrorHandler.ShowErrors(e, "On Download File Completed"); } _isChecking = false; }