private async Task UpdateExisting(GroupContent mod, IAuthProvider provider, IAbsoluteDirectoryPath rsyncDir, IAbsoluteDirectoryPath folder, Action <SyncOptions> config = null) { SetupHosts(mod, provider); var repo = GetRepo(rsyncDir, folder, config); await repo.Update(config).ConfigureAwait(false); }
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; };
private void SetupHosts(GroupContent mod, IAuthProvider provider) { foreach (var h in GetHosts(mod)) { provider.SetNonPersistentAuthInfo(h, new AuthInfo(Access.UserName, Access.Password)); } }
private async Task InstallNew(GroupContent mod, IAuthProvider provider, Action<SyncOptions> config, IAbsoluteDirectoryPath folder) { SetupHosts(mod, provider); var opts = new SyncOptions(); config(opts); await Repository.Factory.Clone(opts.Hosts, folder.ToString(), config) .ConfigureAwait(false); }
private async Task InstallNew(GroupContent mod, IAuthProvider provider, Action <SyncOptions> config, IAbsoluteDirectoryPath folder) { SetupHosts(mod, provider); var opts = new SyncOptions(); config(opts); await Repository.Factory.Clone(opts.Hosts, folder.ToString(), config) .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); }
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); }
private async Task UpdateExisting(GroupContent mod, IAuthProvider provider, IAbsoluteDirectoryPath rsyncDir, IAbsoluteDirectoryPath folder, Action<SyncOptions> config = null) { SetupHosts(mod, provider); var repo = GetRepo(rsyncDir, folder, config); await repo.Update(config).ConfigureAwait(false); }
// TODO: Id vs PackageName? public IReadOnlyCollection<Uri> GetHosts(GroupContent content) => new[] {new Uri(baseHost, Id.ToShortId() + "/" + content.GameId.ToShortId() + "/" + content.PackageName)};
// TODO private bool IsRightVersion(IAbsoluteDirectoryPath rsyncDir, GroupContent mod) => false;
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; };
// TODO: Id vs PackageName? public IReadOnlyCollection <Uri> GetHosts(GroupContent content) => new[] { new Uri(baseHost, Id.ToShortId() + "/" + content.GameId.ToShortId() + "/" + content.PackageName) };