Inheritance: BaseEntityGuidId
Example #1
0
 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);
 }
Example #2
0
 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;
 };
Example #3
0
 private void SetupHosts(GroupContent mod, IAuthProvider provider)
 {
     foreach (var h in GetHosts(mod))
     {
         provider.SetNonPersistentAuthInfo(h,
                                           new AuthInfo(Access.UserName, Access.Password));
     }
 }
Example #4
0
 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);
 }
Example #5
0
        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);
        }
Example #6
0
        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);
        }
Example #7
0
        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);
        }
Example #8
0
 private void SetupHosts(GroupContent mod, IAuthProvider provider) {
     foreach (var h in GetHosts(mod)) {
         provider.SetNonPersistentAuthInfo(h,
             new AuthInfo(Access.UserName, Access.Password));
     }
 }
Example #9
0
 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);
 }
Example #10
0
 // TODO: Id vs PackageName?
 public IReadOnlyCollection<Uri> GetHosts(GroupContent content)
     => new[] {new Uri(baseHost, Id.ToShortId() + "/" + content.GameId.ToShortId() + "/" + content.PackageName)};
Example #11
0
 // TODO
 private bool IsRightVersion(IAbsoluteDirectoryPath rsyncDir, GroupContent mod) => false;
Example #12
0
 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;
 };
Example #13
0
 // TODO: Id vs PackageName?
 public IReadOnlyCollection <Uri> GetHosts(GroupContent content)
 => new[] { new Uri(baseHost, Id.ToShortId() + "/" + content.GameId.ToShortId() + "/" + content.PackageName) };
Example #14
0
 // TODO
 private bool IsRightVersion(IAbsoluteDirectoryPath rsyncDir, GroupContent mod) => false;