public void ProgressDownloadingFlatTest() { SUT = new ProgressComponent("Stage"); var networkMods = new ProgressComponent("Network mods"); var networkModsDownloads = new ProgressLeaf("Downloading"); networkModsDownloads.Update(500, 50); networkMods.AddComponents(networkModsDownloads); var groupMods = new ProgressComponent("Group mods"); groupMods.AddComponents(new ProgressLeaf("Mod 3")); SUT.AddComponents(networkMods, groupMods); var sut = SUT.Flatten(); sut[0].Title.Should().Be("Stage"); sut[0].Progress.Should().Be(25); sut[0].ComponentsCount.Should().Be(2); sut[0].CurrentStage.Should().Be(1); sut[0].Speed.Should().Be(500); sut[1].Title.Should().Be("Network mods"); sut[1].Progress.Should().Be(50); sut[1].ComponentsCount.Should().Be(1); sut[1].CurrentStage.Should().Be(1); sut[1].Speed.Should().Be(500); sut[2].Title.Should().Be("Downloading"); sut[2].Progress.Should().Be(50); sut[2].ComponentsCount.Should().Be(0); sut[2].CurrentStage.Should().Be(0); sut[2].Speed.Should().Be(500); }
public void FlatProgressTest() { SUT = new ProgressComponent("Stage"); var networkMods = new ProgressComponent("Network mods"); var networkModsDownloads = new ProgressLeaf("Downloading").Finished(); var networkModsExtraction = new ProgressComponent("Extracting"); networkModsExtraction.AddComponents(new ProgressLeaf("Mod 1").Finished(), new ProgressLeaf("Mod 2")); networkMods.AddComponents(networkModsDownloads, networkModsExtraction); var groupMods = new ProgressComponent("Group mods"); groupMods.AddComponents(new ProgressLeaf("Mod 3")); SUT.AddComponents(networkMods, groupMods); var sut = SUT.Flatten(); sut[0].Title.Should().Be("Stage"); sut[0].Progress.Should().Be(37.5); sut[0].ComponentsCount.Should().Be(2); sut[0].CurrentStage.Should().Be(1); sut[0].Speed.Should().Be(null); sut[1].Title.Should().Be("Network mods"); sut[1].Progress.Should().Be(75); sut[1].ComponentsCount.Should().Be(2); sut[1].CurrentStage.Should().Be(2); sut[1].Speed.Should().Be(null); sut[2].Title.Should().Be("Extracting"); sut[2].Progress.Should().Be(50); sut[2].ComponentsCount.Should().Be(2); sut[2].CurrentStage.Should().Be(2); sut[2].Speed.Should().Be(null); }
public static IDisposable Monitor(this StatusRepo This, ProgressLeaf leaf, bool inclProgress = false) { var c = new AverageContainer2(20); var isZero = true; return(new RepoWatcher(This, current => Call(leaf, inclProgress, c, current.Speed, current.Progress))); }
public void TestProgressWithCustomWeight() { SUT = new ProgressComponent("Stage"); var mods = GetTestMods(); var nMods = mods.Where(x => x.Type == ModType.Network).ToArray(); var networkMods = new ProgressComponent("Network mods", nMods.Length); var networkModsDownloads = new ProgressLeaf("Downloading").Finished(); var networkModsExtraction = new ProgressComponent("Extracting"); networkModsExtraction.AddComponents(new ProgressLeaf(nMods[0].Name).Finished(), new ProgressLeaf(nMods[1].Name)); networkMods.AddComponents(networkModsDownloads, networkModsExtraction); SUT.AddComponents(networkMods); var gMods = mods.Where(x => x.Type == ModType.Group).ToArray(); var groupMods = new ProgressComponent("Group mods", gMods.Length); var groupModsProcessing = new ProgressComponent("Processing"); groupModsProcessing.AddComponents(gMods.Select(x => new ProgressLeaf(x.Name)).ToArray()); groupMods.AddComponents(groupModsProcessing); SUT.AddComponents(groupMods); networkModsDownloads.Progress.Should().Be(100); networkModsExtraction.Progress.Should().Be(50); networkMods.Progress.Should().Be(75); groupMods.Progress.Should().Be(0); groupModsProcessing.Progress.Should().Be(0); SUT.Progress.Should().Be(50); SUT.StatusText.Should().Be("Stage 1/2 50%\nNetwork mods 2/2 75%\nExtracting 2/2 50%\nDone"); }
void HandleChangesWithRemove(IEnumerable <FileObjectMapping> mappings, Package.ChangeList changeAg, ProgressLeaf progressLeaf) { HandleCopy(changeAg.Copy, changeAg.StatusDic); HandleRemove(changeAg.Remove, changeAg.StatusDic); HandleChangedCase(changeAg.ChangedCase, changeAg.StatusDic); HandleModify(Convert(mappings, changeAg.GetModified()).ToArray(), changeAg.StatusDic, progressLeaf); }
public static PackageProgress SetupSynqProgress(string title = "Network mods") { var packageFetching = new ProgressLeaf("Preparing"); var networkModsProcessing = new ProgressContainer("Downloading", 9); var cleanup = new ProgressLeaf("Cleaning"); return(new PackageProgress { PackageFetching = packageFetching, Processing = networkModsProcessing, Cleanup = cleanup }); }
public void TestProgressDownloading() { SUT = new ProgressComponent("Stage"); var networkMods = new ProgressComponent("Network mods"); var networkModsDownloads = new ProgressLeaf("Downloading"); networkModsDownloads.Update(500, 50); networkMods.AddComponents(networkModsDownloads); var groupMods = new ProgressComponent("Group mods"); groupMods.AddComponents(new ProgressLeaf("Mod 3")); SUT.AddComponents(networkMods, groupMods); SUT.StatusText.Should().Be("Stage 1/2 25%\nNetwork mods 1/1 50%\nDownloading 50% @ 500 B/s"); }
void HandleModify(ICollection <FileObjectMapping> modify, IDictionary <string, Status> statusDic, ProgressLeaf progressLeaf) { StatusRepo.ResetWithoutClearItems(RepoStatus.Unpacking, modify.Count); var i = 0; modify.OrderByDescending(x => Tools.FileUtil.SizePrediction(x.FilePath)) .ForEach(m => { ProcessModified(statusDic, m, (p, s) => progressLeaf?.Update(null, (i + p / 100).ToProgress(modify.Count))); StatusRepo.IncrementDone(); progressLeaf?.Update(null, i++.ToProgress(modify.Count)); }); progressLeaf?.Finish(); }
private async Task ProcessPackageInternal(Package package, ProgressLeaf p) { Repository.Log("\nChecking out {0} into {1}, please be patient...", package.MetaData.GetFullName(), package.WorkingPath); switch (Settings.CheckoutType) { case CheckoutType.NormalCheckout: await package.CheckoutAsync(p).ConfigureAwait(false); break; case CheckoutType.CheckoutWithoutRemoval: await package.CheckoutWithoutRemovalAsync(p).ConfigureAwait(false); break; default: throw new ArgumentOutOfRangeException(); } }
public void TestProgress2() { SUT = new ProgressComponent("Stage"); var networkMods = new ProgressComponent("Network mods"); var networkModsDownloads = new ProgressLeaf("Downloading").Finished(); var networkModsExtraction = new ProgressComponent("Extracting"); networkModsExtraction.AddComponents(new ProgressLeaf("Mod 1").Finished(), new ProgressLeaf("Mod 2")); networkMods.AddComponents(networkModsDownloads, networkModsExtraction); var groupMods = new ProgressComponent("Group mods"); groupMods.AddComponents(new ProgressLeaf("Mod 3")); SUT.AddComponents(networkMods, groupMods); networkModsDownloads.Progress.Should().Be(100); networkModsExtraction.Progress.Should().Be(50); networkMods.Progress.Should().Be(75); groupMods.Progress.Should().Be(0); SUT.Progress.Should().Be(37.5); }
void ProcessCheckout(ProgressLeaf progressLeaf, bool withRemoval = true, bool confirmChecksums = true) { HandleDownCase(); var mappings = GetMetaDataFilesOrderedBySize(); var changeAg = GetInitialChangeList(withRemoval, mappings); TryCrippleSixSyncIfExists(); if (withRemoval) { HandleChangesWithRemove(mappings, changeAg, progressLeaf); } else { HandleChanges(mappings, changeAg, progressLeaf); } if (confirmChecksums) { ConfirmChanges(withRemoval, mappings); } }
private static void Call(ProgressLeaf leaf, bool inclProgress, AverageContainer2 c, long?speed, double progress) { leaf.Update(c.UpdateSpecial(speed), inclProgress ? progress : leaf.Progress); }
public Task CheckoutAsync(ProgressLeaf progressLeaf, bool confirmChecksums = true) => TaskExt.StartLongRunningTask(() => Checkout(progressLeaf, confirmChecksums));
public async Task DownloadPackages(Dictionary <IAbsoluteDirectoryPath, FileObjectMapping[]> dict, IAbsoluteDirectoryPath downloadPath, Uri[] hosts, StatusRepo status, ProgressLeaf cleanup, ProgressContainer progress) { await ProcessChanges(dict, downloadPath, hosts, status, progress).ConfigureAwait(false); // find all files that are too many, and delete them if (cleanup != null) { PerformCleanup(dict, cleanup); } }
public Task DownloadPackages(Package[] p, IAbsoluteDirectoryPath downloadPath, Uri[] hosts, StatusRepo status, ProgressLeaf cleanup, ProgressContainer progress) => DownloadPackages(TransformPackages(p), downloadPath, hosts, status, cleanup, progress);
private static void PerformCleanup(Dictionary <IAbsoluteDirectoryPath, FileObjectMapping[]> dict, ProgressLeaf status) => status.Do(() => PerformCleanupInternal(dict, status));
void OnCheckoutWithoutRemoval(ProgressLeaf progressLeaf) { WorkingPath.MakeSurePathExists(); ProcessCheckout(progressLeaf, false); }
public void CheckoutWithoutRemoval(ProgressLeaf progressLeaf) { OnCheckoutWithoutRemoval(progressLeaf); UpdateTag(); }
public void Checkout(ProgressLeaf progressLeaf, bool confirmChecksums = true) { WorkingPath.MakeSurePathExists(); ProcessCheckout(progressLeaf, true, confirmChecksums); WriteTag(); }
public Task CheckoutWithoutRemovalAsync(ProgressLeaf progressLeaf) => TaskExt.StartLongRunningTask(() => CheckoutWithoutRemoval(progressLeaf));