public async Task <string[]> Update(IEnumerable <Uri> remotes, StatusRepo repo, bool skipWhenFileMatches = true) { var objects = GetNeededObjects(skipWhenFileMatches); var doneObjects = new ConcurrentBag <FileObjectMapping>(); var relObjects = objects.OrderByDescending(x => Tools.FileUtil.SizePrediction(x.FO.FilePath)) .Select( x => new FileFetchInfo(Repository.GetObjectSubPath(x.FO), x.FO.FilePath) { OnComplete = () => doneObjects.Add(x.FO) }) .ToArray(); StatusRepo.ProcessSize(GetExistingObjects(objects.Select(x => x.FO)), Repository.ObjectsPath, MetaData.SizePacked); // TODO: Abort support! // TODO: Progress fix??! try { await DownloadObjects(remotes, repo, relObjects, Repository.ObjectsPath).ConfigureAwait(false); } finally { Repository.ReAddObject(doneObjects.Select(x => x.Checksum).ToArray()); } return(relObjects.Select(x => x.FilePath).ToArray()); }
private void Status_Load(object sender, EventArgs e) { List <SMLIB.Entity.Status> statuses = StatusRepo.retrieve(); fillListView(statuses); clearAll(); }
private void btnCategoryUpdate_Click(object sender, EventArgs e) { try { if (txtStatus.Text != "") { bool d = StatusRepo.checkIfStatusExists(txtStatus.Text); if (d) { MessageBox.Show("This status already exists"); } else { StatusRepo.update(this.id, txtStatus.Text); MessageBox.Show("Status has been updated."); List <SMLIB.Entity.Status> statuses = StatusRepo.retrieve(); fillListView(statuses); btnCategoryDelete.Enabled = false; btnCategoryUpdate.Enabled = false; btnCategoryAdd.Enabled = true; clearAll(); } } else { MessageBox.Show("Status has been updated."); } } catch (Exception) { MessageBox.Show("Please select an item to update."); } }
private async Task GetDependencyTreeInternal(IReadOnlyCollection <Dependency> dependencies, bool noCheckout, bool useFullName, List <string> list, List <string> list2, List <Package> packages) { StatusRepo.Reset(RepoStatus.Resolving, dependencies.Count); var specificVersions = dependencies.Select(x => ResolvePackageName(x.GetFullName())).ToArray(); await FetchAllRequestedPackages(specificVersions).ConfigureAwait(false); var done = specificVersions.ToList(); foreach (var dep in specificVersions) { Repo.AddPackage(dep.GetFullName()); await ResolveDependencies(list, list2, packages, dep, done, useFullName, noCheckout) .ConfigureAwait(false); } foreach (var package in packages) { package.StatusRepo = StatusRepo; } if (packages.GroupBy(x => x.MetaData.Name.ToLower()).Any(x => x.Count() > 1)) { throw new InvalidOperationException("Somehow got duplicate packges: " + string.Join(", ", packages.GroupBy(x => x.MetaData.Name.ToLower()) .Where(x => x.Count() > 1) .Select(x => x.Key))); } }
async Task <string[]> UpdateMultiple(IReadOnlyCollection <Package.ObjectMap> objects, IReadOnlyCollection <Package> packages, IReadOnlyCollection <Uri> remotes) { if (!objects.Any()) { Repository.Log("No remote objects to resolve"); return(new string[0]); } Repository.Log("Resolving {0} remote objects for {1} packages from {2} remotes, please be patient..", objects.Count, packages.Count, remotes.Count); var doneObjects = new ConcurrentBag <FileObjectMapping>(); var relObjects = objects.OrderByDescending(x => Tools.FileUtil.SizePrediction(x.FO.FilePath)) .Select(x => new FileFetchInfo(Repo.GetObjectSubPath(x.FO), x.FO.FilePath) { ExistingPath = x.ExistingObject != null ? Repo.GetObjectSubPath(x.ExistingObject) : null, OnComplete = () => doneObjects.Add(x.FO) }) .ToArray(); StatusRepo.Reset(RepoStatus.Downloading, objects.Count); StatusRepo.ProcessSize(GetExistingObjects(objects.Select(x => x.FO), packages), Repo.ObjectsPath, GetPackedSize(packages)); try { await Package.DownloadObjects(remotes, StatusRepo, relObjects, Repo.ObjectsPath).ConfigureAwait(false); } finally { Repo.ReAddObject(doneObjects.Select(x => x.Checksum).ToArray()); } return(relObjects.Select(x => x.FilePath).ToArray()); }
public RepoWatcher(StatusRepo repo) { _timer = new TimerWithElapsedCancellation(TimerTime, () => { repo.UpdateTotals(); return(true); }); }
// TODO: localOnly if no update available? - so for local diagnose etc.. public async Task GetMod(string name, IAbsoluteDirectoryPath destination, IAbsoluteDirectoryPath packPath, StatusRepo status, bool force = false) { var mod = GetMod(name); var folder = destination.GetChildDirectoryWithName(mod.Key); var config = GetOpts(packPath, status, mod); if (!folder.Exists) { var opts = new SyncOptions(); config(opts); await Repository.Factory.Clone(opts.Hosts, folder.ToString(), config) .ConfigureAwait(false); return; } var rsyncDir = folder.GetChildDirectoryWithName(Repository.RepoFolderName); if (!force && rsyncDir.Exists && IsRightVersion(rsyncDir, mod)) { return; } var repo = GetRepo(rsyncDir, folder, config); await repo.Update(config).ConfigureAwait(false); }
Dictionary <string, object> GetOptions(StatusRepo status, string packPath = null, bool allowFallback = false) { var opts = new Dictionary <string, object> { { "hosts", GetHosts() }, { "max_threads", GetMaxThreads() }, { "keep_compressed_files", DomainEvilGlobal.Settings.AppOptions.KeepCompressedFiles }, { "protocol_preference", DomainEvilGlobal.Settings.AppOptions.ProtocolPreference }, { "required_version", (long?)_mod.Version.TryIntNullable() }, { "required_guid", _mod.Guid }, { "allow_full_transfer_fallback", allowFallback }, { "output", "none" } }; if (status != null) { opts.Add("status", status); } if (!String.IsNullOrWhiteSpace(packPath)) { opts["pack_path"] = Repository.RepoTools.GetNewPackPath(packPath, _path.DirectoryName, _modState.Guid); } return(opts); }
protected override async Task<int> RunAsync(params string[] remainingArguments) { using (var statusRepo = new StatusRepo()) using (new ConsoleProgress(statusRepo)) await _toolsInstaller.DownloadAndInstallTools(statusRepo).ConfigureAwait(false); return 0; }
public PackageManager(Repository repo, IAbsoluteDirectoryPath workDir, bool createWhenNotExisting = false, string remote = null) { Contract.Requires<ArgumentNullException>(repo != null); Contract.Requires<ArgumentNullException>(workDir != null); WorkDir = workDir; Repo = repo; StatusRepo = new StatusRepo(); Settings = new PackageManagerSettings(); Repository.Factory.HandlePathRequirements(WorkDir, Repo); if (!WorkDir.Exists) { if (!createWhenNotExisting) throw new Exception("Workdir doesnt exist"); WorkDir.MakeSurePathExists(); } if (!string.IsNullOrWhiteSpace(remote)) { var config = Repository.DeserializeJson<RepositoryConfigDto>( FetchString(Tools.Transfer.JoinUri(new Uri(remote), "config.json"))); if (config.Uuid == Guid.Empty) throw new Exception("Invalid remote, does not contain an UUID"); Repo.AddRemote(config.Uuid, remote); Repo.Save(); } Repository.Log("Opening repository at: {0}. Working directory at: {1}", Repo.RootPath, WorkDir); _remote = remote; }
async Task InstallToolsIfNeeded(CancellationToken token) { if (await _toolsInstaller.ConfirmToolsInstalled(true).ConfigureAwait(false)) return; var repo = new StatusRepo(token) {Action = RepoStatus.Downloading}; //using (new RepoWatcher(repo)) //using (new StatusRepoMonitor(repo, (Func<double, double, Task>)StatusChange)) await _toolsInstaller.DownloadAndInstallTools(repo).ConfigureAwait(false); }
public void ListAllStatusesDBTest() { var repo = new StatusRepo(); List <Status> statuses = repo.GetAllStatuses(); var expected = 4; Assert.AreEqual(expected, statuses.Count); }
Action <SyncOptions> GetOpts(IAbsoluteDirectoryPath packPath, StatusRepo status, GroupContent mod) => opts => { opts.Hosts = GetHosts(mod).ToList(); //{"required_version", mod.Version}, // TODO //{"required_guid", @group.Id}, // TODO opts.PackPath = packPath.GetChildDirectoryWithName(mod.PackageName); opts.Status = status; };
Action <SyncOptions> GetOpts(IAbsoluteDirectoryPath packPath, StatusRepo status, KeyValuePair <string, SixRepoModDto> mod) => opt => { opt.Hosts = Hosts.Select(x => new Uri(x, mod.Key)).ToList(); opt.RequiredVersion = mod.Value.Version; opt.RequiredGuid = mod.Value.Guid; opt.PackPath = packPath.GetChildDirectoryWithName(mod.Key); opt.Status = status; };
void HandleCopy(ICollection <KeyValuePair <string, List <string> > > copy, IDictionary <string, Status> statusDic) { StatusRepo.ResetWithoutClearItems(RepoStatus.Copying, copy.Count); copy.ForEach(x => { x.Value.ForEach(y => CopyExistingWorkingFile(statusDic, y, x.Key)); StatusRepo.IncrementDone(); }); }
static IDictionary <FileFetchInfo, ITransferStatus> GetTransferDictionary( StatusRepo sr, IEnumerable <FileFetchInfo> files) => files.OrderByDescending(x => Tools.FileUtil.SizePrediction(x.FilePath)) .ToDictionary(x => x, x => (ITransferStatus) new Status(x.DisplayName, sr) { RealObject = x.FilePath, OnComplete = x.Complete });
public DownloadAndInstaller(IFileDownloader downloader, StatusRepo statusRepo, string file, IAbsoluteDirectoryPath destination, IRestarter restarter) { _downloader = downloader; _statusRepo = statusRepo; _file = file; _destination = destination; _restarter = restarter; _sourceFile = Common.Paths.TempPath.GetChildFileWithName(_file); _progress = new Status(_file, statusRepo, 0, 0, default(TimeSpan?), RepoStatus.Downloading); }
static void MigrateServerMods(IEnumerable<string> folders, IAbsoluteDirectoryPath modPath, StatusRepo statusRepo) { foreach (var folder in folders) { foreach (var modFolder in Directory.EnumerateDirectories(folder)) { var status = new Status(Path.GetFileName(modFolder), statusRepo) {Action = RepoStatus.Processing}; MigrateServerModFolder(modFolder.ToAbsoluteDirectoryPath(), modPath); status.Progress = 100; } Directory.Delete(folder, true); } }
public async Task DownloadFilesAsync(IReadOnlyCollection <Uri> remotes, StatusRepo sr, IDictionary <FileFetchInfo, ITransferStatus> transferStatuses, IAbsoluteDirectoryPath destination) { sr.Action = RepoStatus.Downloading; using (var scoreMirrorSelector = _createMirrorSelector(remotes)) { await DownloadFilesAsync(sr, transferStatuses, destination, scoreMirrorSelector.Value) .ConfigureAwait(false); } }
public FileDownloadManager(StatusRepo repo, IEnumerable <Uri> hosts, MultiThreadingSettings multiThreadingSettings, IFileDownloader downloader, Func <ExportLifetimeContext <IHostChecker> > hostChecker) : this( new HostPicker( hosts.Select( x => new Uri(x.ToString().Replace("http://", "zsync://").Replace("https://", "zsyncs://"))), multiThreadingSettings, hostChecker), repo, downloader) { }
static void Status(string patchFile, StatusRepo repo, Action <IStatus> act, RepoStatus action = RepoStatus.Downloading) { var status = new Status(patchFile, repo) { Action = action }; act(status); status.EndOutput(); }
public async Task ConvertOrInstallOrUpdateSixSync(bool force, StatusRepo statusRepo, IAbsoluteDirectoryPath packPath) { UpdateState(); try { await _sixSyncModInstaller.ConvertOrInstallOrUpdateInternal(Path, force, statusRepo, _modState, packPath) .ConfigureAwait(false); } finally { UpdateState(); } }
void HandleRemove(List <string> remove, IDictionary <string, Status> statusDic) { StatusRepo.ResetWithoutClearItems(RepoStatus.Removing, remove.Count()); remove.ForEach(x => ProcessRemoved(statusDic, x)); foreach (var d in GetEmptyDirectories(remove)) { Tools.FileUtil.Ops.DeleteDirectory(d); StatusRepo.IncrementDone(); } }
public async Task <List <Package> > Checkout(IReadOnlyCollection <string> packageNames, bool?useFullNameOverride = null) { StatusRepo.Reset(RepoStatus.CheckOut, packageNames.Count()); var packages = new List <Package>(); foreach (var p in packageNames) { packages.Add(await CheckoutAsync(p, useFullNameOverride).ConfigureAwait(false)); } return(packages); }
async Task DownloadFilesAsync(StatusRepo sr, IDictionary <FileFetchInfo, ITransferStatus> transferStatuses, IAbsoluteDirectoryPath destinationPath, IMirrorSelector scoreMirrorSelector) { destinationPath.MakeSurePathExists(); sr.Total = transferStatuses.Count; using (var multiMirrorFileDownloader = _createMultiMirrorFileDownloader(scoreMirrorSelector)) using (var multi = _createQueueDownloader(multiMirrorFileDownloader.Value)) { await multi.Value .DownloadAsync(CreateFileQueueSpec(transferStatuses, destinationPath), sr.CancelToken) .ConfigureAwait(false); } }
async Task TryInstallToolsIfNeeded() { if (await _toolsInstaller.ConfirmToolsInstalled(true).ConfigureAwait(false)) { return; } var repo = new StatusRepo { Action = RepoStatus.Downloading }; await _repoActionHandler.PerformStatusActionWithBusyHandlingAsync(repo, "Tools", () => _toolsInstaller.DownloadAndInstallTools(repo)).ConfigureAwait(false); }
async Task InstallToolsIfNeeded(CancellationToken token) { if (await _toolsInstaller.ConfirmToolsInstalled(true).ConfigureAwait(false)) { return; } var repo = new StatusRepo(token) { Action = RepoStatus.Downloading }; //using (new RepoWatcher(repo)) //using (new StatusRepoMonitor(repo, (Func<double, double, Task>)StatusChange)) await _toolsInstaller.DownloadAndInstallTools(repo).ConfigureAwait(false); }
public async Task GetMod(GroupContent mod, IAbsoluteDirectoryPath destination, IAbsoluteDirectoryPath packPath, StatusRepo status, IAuthProvider provider, bool force = false) { var folder = destination.GetChildDirectoryWithName(mod.PackageName); if (!folder.Exists) { await InstallNew(mod, provider, GetOpts(packPath, status, mod), folder).ConfigureAwait(false); return; } var rsyncDir = folder.GetChildDirectoryWithName(Repository.RepoFolderName); if (!force && rsyncDir.Exists && IsRightVersion(rsyncDir, mod)) return; await UpdateExisting(mod, provider, rsyncDir, folder, GetOpts(packPath, status, mod)).ConfigureAwait(false); }
async Task DownloadFiles(IEnumerable <FileFetchInfo> remoteFiles, CancellationToken token) { var retryLimit = 6; var statusRepo = new StatusRepo(token); await SyncEvilGlobal.DownloadHelper.DownloadFilesAsync(Urls, statusRepo, remoteFiles.ToDictionary(x => x, x => (ITransferStatus) new TransferStatus(x.FilePath) { ZsyncHttpFallbackAfter = CalculateHttpFallbackAfter(retryLimit) }), Path, retryLimit).ConfigureAwait(false); }
public async Task <Package[]> ProcessPackages(IEnumerable <Dependency> packageNames, bool?useFullNameOverride = null, bool noCheckout = false, bool skipWhenFileMatches = true) { if (Repo.Config.OperationMode == RepositoryOperationMode.SinglePackage) { throw new Exception("Cannot process repository in SinglePackage mode"); } var useFullName = Repo.Config.UseVersionedPackageFolders; if (useFullNameOverride.HasValue) { useFullName = useFullNameOverride.Value; } // Add this package, then add it's dependencies, and so on // The list should be unique based on package (name + version + branch) // If there is a conflict, the process should be aborted. A conflict can arise when one package needs a version locked on X, and another on Y // First resolve all dependencies // So that we can determine conflicting dependencies, remove double dependencies, etc. // Let the package Download itself, by providing it with sources (remotes) var packages = (await GetDependencyTree(packageNames.ToArray(), noCheckout, useFullName).ConfigureAwait(false)) .OrderByDescending(x => x.MetaData.SizePacked).ToArray(); StatusRepo.Reset(RepoStatus.Processing, packages.Length); if (Settings.GlobalWorkingPath != null) { var s = Settings.GlobalWorkingPath.ToString(); foreach (var p in packages) { p.SetWorkingPath(s); } } if (LegacyMode) { await ProcessLegacy(noCheckout, skipWhenFileMatches, packages).ConfigureAwait(false); } else { await ProcessModern(noCheckout, packages).ConfigureAwait(false); } await Repo.SaveAsync().ConfigureAwait(false); return(packages.ToArray()); }
public void PerformStatusActionWithBusyHandling(StatusRepo repo, string actionText, Action act) { if (repo == null) { throw new ArgumentNullException(nameof(repo)); } if (actionText == null) { throw new ArgumentNullException(nameof(actionText)); } if (act == null) { throw new ArgumentNullException(nameof(act)); } }
private void button1_Click(object sender, EventArgs e) { if (txtCategorySearch.Text != "") { List <SMLIB.Entity.Status> statuses = StatusRepo.retrieveByName(txtCategorySearch.Text); if (statuses.Count > 0) { fillListView(statuses); } else { MessageBox.Show("Status not found."); } } }
public async Task DownloadAndInstallTools(StatusRepo repo) { await DownloadAndInstall(repo, ToolsFile, _destination.ParentDirectoryPath).ConfigureAwait(false); CheckPaths(); if (!CheckToolFilesExist()) { throw new ToolsFilesInstallFailedException( "Something appears to have gone wrong, some tools are missing, please try again :("); } await UpdateInstalledVersionInfo().ConfigureAwait(false); }
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(); }
async Task DownloadChangedAndNewMissions(IEnumerable <Mission> missions, IAbsoluteDirectoryPath destination, StatusRepo repo, string type = "missions") { var location = Path.Combine(destination.ToString(), type).ToAbsoluteDirectoryPath(); var downloadDictionary = await GetMissionsToDownload(missions, location, repo).ConfigureAwait(false); if (downloadDictionary.Any()) { await SyncEvilGlobal.DownloadHelper.DownloadFilesAsync( Config.Hosts.Select(x => Tools.Transfer.JoinUri(x, type)).ToArray(), repo, downloadDictionary, location, 15).ConfigureAwait(false); } }
public Repository(IZsyncMake zsyncMake, StatusRepo statusRepo, string folder = ".") { Contract.Requires<ArgumentNullException>(folder != null); Contract.Requires<ArgumentNullException>(!string.IsNullOrWhiteSpace(folder)); _zsyncMake = zsyncMake; Folder = RepoTools.GetRootedPath(folder); RsyncFolder = Folder.GetChildDirectoryWithName(RepoFolderName); if (!RsyncFolder.Exists) throw new Exception("Not a SixSync repository"); ConfigFile = GetRsyncFile(ConfigFileName); RepoName = Folder.DirectoryName; StatusRepo = statusRepo; Output = "print"; MultiThreadingSettings = new MultiThreadingSettings(); LoadConfig(true); LoadVersions(); }
public async Task ConvertOrInstallOrUpdateInternal(IAbsoluteDirectoryPath path, bool force, StatusRepo statusRepo, ModState modState, IAbsoluteDirectoryPath packPath) { Contract.Requires<ArgumentNullException>(path != null); Contract.Requires<ArgumentNullException>(statusRepo != null); Contract.Requires<ArgumentNullException>(modState != null); _path = path; var opts = GetOptions(statusRepo, packPath.ToString(), force); if (!modState.Exists) { await Install(opts).ConfigureAwait(false); return; } var updateAvailable = modState.State != ContentState.Uptodate; if (modState.DoesRepoExist()) await Update(opts, null, !updateAvailable).ConfigureAwait(false); else { var repo = Convert(opts); await Update(opts, repo).ConfigureAwait(false); } }
// TODO: localOnly if no update available? - so for local diagnose etc.. public async Task GetMod(string name, IAbsoluteDirectoryPath destination, IAbsoluteDirectoryPath packPath, StatusRepo status, bool force = false) { var mod = GetMod(name); var folder = destination.GetChildDirectoryWithName(mod.Key); var config = GetOpts(packPath, status, mod); if (!folder.Exists) { var opts = new SyncOptions(); config(opts); await Repository.Factory.Clone(opts.Hosts, folder.ToString(), config) .ConfigureAwait(false); return; } var rsyncDir = folder.GetChildDirectoryWithName(Repository.RepoFolderName); if (!force && rsyncDir.Exists && IsRightVersion(rsyncDir, mod)) return; var repo = GetRepo(rsyncDir, folder, config); await repo.Update(config).ConfigureAwait(false); }
Dictionary<string, object> GetOptions(StatusRepo status, string packPath = null, bool allowFallback = false) { var opts = new Dictionary<string, object> { {"hosts", GetHosts()}, {"max_threads", GetMaxThreads()}, {"keep_compressed_files", DomainEvilGlobal.Settings.AppOptions.KeepCompressedFiles}, {"protocol_preference", DomainEvilGlobal.Settings.AppOptions.ProtocolPreference}, {"required_version", (long?) _mod.Version.TryIntNullable()}, {"required_guid", _mod.Guid}, {"allow_full_transfer_fallback", allowFallback}, {"output", "none"} }; if (status != null) opts.Add("status", status); if (!String.IsNullOrWhiteSpace(packPath)) { opts["pack_path"] = Repository.RepoTools.GetNewPackPath(packPath, _path.DirectoryName, _modState.Guid); } return opts; }
void InstallOfficialPatch(string patchFile, IAbsoluteDirectoryPath tempPath, StatusRepo repo) { using (new TmpDirectory(tempPath)) Status(patchFile, repo, status => InstallOfficialPatchInternal(patchFile, tempPath, status)); }
static void Status(string patchFile, StatusRepo repo, Action<IStatus> act, RepoStatus action = RepoStatus.Downloading) { var status = new Status(patchFile, repo) {Action = action}; act(status); status.EndOutput(); }
public async Task PerformStatusActionAsync(string actionText, Func<StatusRepo, Task> act) { using (var repo = new StatusRepo()) await PerformStatusActionAsync(actionText, () => act(repo), repo).ConfigureAwait(false); }
void PerformStatusAction(string actionText, Action act, StatusRepo repo) { using (new ActiveMod(this, new StatusMod(actionText) {Repo = repo})) using (new RepoWatcher(repo)) act(); }
public void PerformStatusAction(string actionText, Action<StatusRepo> act) { using (var repo = new StatusRepo()) PerformStatusAction(actionText, () => act(repo), repo); }
public async Task PerformStatusActionWithBusyHandlingAsync(StatusRepo repo, string actionText, Func<Task> act) { using (_busyStateHandler.StartSession()) await PerformStatusActionAsync(actionText, act, repo).ConfigureAwait(false); }
async Task PerformStatusActionAsync(string actionText, Func<Task> act, StatusRepo repo) { using (new ActiveMod(this, new StatusMod(actionText) {Repo = repo})) using (new RepoWatcher(repo)) await act().ConfigureAwait(false); }
static string GetActiveComponent(StatusRepo statusRepo) { return statusRepo.Info.Active > 0 ? " (" + statusRepo.Info.Active + ")" : ""; }
async Task TryInstallToolsIfNeeded() { if (await _toolsInstaller.ConfirmToolsInstalled(true).ConfigureAwait(false)) return; using (var repo = new StatusRepo {Action = RepoStatus.Downloading}) { await _repoActionHandler.PerformStatusActionWithBusyHandlingAsync(repo, "Tools", () => _toolsInstaller.DownloadAndInstallTools(repo)).ConfigureAwait(false); } }
public Status(string item, StatusRepo repo, double progress = 0, int speed = 0, TimeSpan? eta = null, RepoStatus action = RepoStatus.Waiting) : base(item, progress, speed, eta, action) { Repo = repo; Repo.AddItem(this); Color = "Green"; }
protected Task DownloadAndInstall(StatusRepo statusRepo, string file, IAbsoluteDirectoryPath destination) { return new DownloadAndInstaller(_downloader, statusRepo, file, destination, _restarter).DownloadAndInstall(); }
public async Task DownloadFilesAsync(IReadOnlyCollection<Uri> remotes, StatusRepo sr, IDictionary<KeyValuePair<string, Func<IAbsoluteFilePath, bool>>, ITransferStatus> transferStatuses, IAbsoluteDirectoryPath destination) { sr.Action = RepoStatus.Downloading; using (var scoreMirrorSelector = _createMirrorSelector(remotes)) { await DownloadFilesAsync(sr, transferStatuses, destination, scoreMirrorSelector) .ConfigureAwait(false); } }
public ConsoleProgress(StatusRepo status) { _status = status; _action = status.Action; _disposable = SetupProgressReporting(); }
Action<SyncOptions> GetOpts(IAbsoluteDirectoryPath packPath, StatusRepo status, GroupContent mod) => opts => { opts.Hosts = GetHosts(mod).ToList(); //{"required_version", mod.Version}, // TODO //{"required_guid", @group.Id}, // TODO opts.PackPath = packPath.GetChildDirectoryWithName(mod.PackageName); opts.Status = status; };
public void PerformStatusActionWithBusyHandling(StatusRepo repo, string actionText, Action act) { using (_busyStateHandler.StartSession()) PerformStatusAction(actionText, act, repo); }
public void MigrateServerMods(Game currentGame, StatusRepo statusRepo) { statusRepo.Action = RepoStatus.Moving; MigrateServerMods(GetServerModFolders(currentGame), currentGame.Modding().ModPaths.Path, statusRepo); }
// Bad but cool static string GetItemComponent(StatusRepo statusRepo) { return statusRepo == null || statusRepo.Total == 0 ? "" : " " + statusRepo.Info.Done + "/" + statusRepo.Total + GetActiveComponent(statusRepo); }
async Task DownloadFilesAsync(StatusRepo sr, IDictionary<KeyValuePair<string, Func<IAbsoluteFilePath, bool>>, ITransferStatus> transferStatuses, IAbsoluteDirectoryPath destinationPath, ExportLifetimeContext<IMirrorSelector> scoreMirrorSelector) { destinationPath.MakeSurePathExists(); sr.Total = transferStatuses.Count; using (var multiMirrorFileDownloader = _createMultiMirrorFileDownloader(scoreMirrorSelector.Value)) using (var multi = _createQueueDownloader(multiMirrorFileDownloader.Value)) { await multi.Value .DownloadAsync(CreateFileQueueSpec(transferStatuses, destinationPath), sr.CancelToken) .ConfigureAwait(false); } }
public virtual async Task DownloadMod(YomaConfig.YomaMod mod) { Config.Addons.Where(x => !File.Exists(Path.Combine(Destination.ToString(), x.Path, x.Pbo)) && FilesDir.GetChildFileWithName(x.Url).Exists).ForEach(UnpackAddon); var remoteFiles = Config.Addons .Where( x => !ConfirmFileValidity(Path.Combine(Destination.ToString(), x.Path, x.Pbo).ToAbsoluteFilePath(), x.Md5)) .Select(x => x.Url); using (var statusRepo = new StatusRepo()) { await _downloader.DownloadFilesAsync(new[] {Url}, statusRepo, remoteFiles.ToDictionary(x => new KeyValuePair<string, Func<IAbsoluteFilePath, bool>>(x, null), x => (ITransferStatus) null), FilesDir).ConfigureAwait(false); } }