public async Task DownloadAsync() { var executableDir = GetCleanExecutableDir(); Assert.AreEqual(false, File.Exists(executableDir)); Assert.AreEqual(true, await IWYUDownload.IsNewerVersionAvailableOnline(executableDir)); // Nothing here practically means that there is a new version. await IWYUDownload.DownloadIWYU(executableDir, ReportProgress, new CancellationToken()); Assert.AreEqual(false, await IWYUDownload.IsNewerVersionAvailableOnline(executableDir)); Assert.AreEqual(true, File.Exists(executableDir)); }
public void Download() { var executableDir = GetCleanExecutableDir(); Assert.AreEqual(false, File.Exists(executableDir)); Assert.AreEqual(true, IWYUDownload.IsNewerVersionAvailableOnline(executableDir).Result); // Nothing here practically means that there is a new version. var downloadTask = IWYUDownload.DownloadIWYU(executableDir, ReportProgress, new CancellationToken()); downloadTask.Wait(); Assert.AreEqual(false, IWYUDownload.IsNewerVersionAvailableOnline(executableDir).Result); Assert.AreEqual(true, File.Exists(executableDir)); }
private async Task OptionalDownloadOrUpdate(IncludeWhatYouUseOptionsPage settings, IVsThreadedWaitDialogFactory dialogFactory) { // Check existence, offer to download if it's not there. bool downloadedNewIwyu = false; if (!File.Exists(settings.ExecutablePath)) { if (await Output.Instance.YesNoMsg($"Can't find include-what-you-use in '{settings.ExecutablePath}'. Do you want to download it from '{IWYUDownload.DisplayRepositorURL}'?") != Output.MessageResult.Yes) { return; } downloadedNewIwyu = await DownloadIWYUWithProgressBar(settings.ExecutablePath, dialogFactory); if (!downloadedNewIwyu) { return; } } else if (settings.AutomaticCheckForUpdates && !checkedForUpdatesThisSession) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); IVsThreadedWaitDialog2 dialog = null; dialogFactory.CreateInstance(out dialog); dialog?.StartWaitDialog("Include Toolbox", "Running Include-What-You-Use", null, null, "Checking for Updates for include-what-you-use", 0, false, true); bool newVersionAvailable = await IWYUDownload.IsNewerVersionAvailableOnline(settings.ExecutablePath); dialog?.EndWaitDialog(); if (newVersionAvailable) { checkedForUpdatesThisSession = true; if (await Output.Instance.YesNoMsg($"There is a new version of include-what-you-use available. Do you want to download it from '{IWYUDownload.DisplayRepositorURL}'?") == Output.MessageResult.Yes) { downloadedNewIwyu = await DownloadIWYUWithProgressBar(settings.ExecutablePath, dialogFactory); } } } if (downloadedNewIwyu) { settings.AddMappingFiles(IWYUDownload.GetMappingFilesNextToIwyuPath(settings.ExecutablePath)); } }