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