Exemplo n.º 1
0
        private RepositoryServerInstance InitAndSynchronizeRepository(Repository dto)
        {
            // create cache
            var cacheRepoAccessor = new Repositories.DirectoryCompressedRepositoryAccessor(Path.Combine(AppCachePath, dto.UrlName), dto.UrlName);
            var cacheRepo = cacheRepoAccessor.FetchRepository().Result;

            // create result instance
            var instance = new RepositoryServerInstance()
            {
                Dto = dto,
                GroupsAllowed = dto.ClientGroups.ToDictionary(cg => cg.Id),
                Value = cacheRepo
            };

            // sync
            try
            {
                SynchronizeRepository(instance).Wait();
            }
            catch(AggregateException ae)
            {
                throw ae.Flatten().InnerException;
            }

            return instance;
        }
Exemplo n.º 2
0
 public bool AuthorizeClientToRepository(RepositoryServerInstance instance, ClaimsIdentity identity)
 {
     var groupIds = GetIdentityGroupsIds(identity);
     bool result = instance.GroupsAllowed.Keys.Any(groupId => groupIds.Contains(groupId));
     return result;
 }
Exemplo n.º 3
0
        public async Task SynchronizeRepository(RepositoryServerInstance instance)
        {
            // TODO: race conditions

            // link to source folder
            var sourceRepoAccessor = new Repositories.DirectoryRepositoryAccessor(instance.Dto.SourceFolder, instance.Dto.UrlName);
            var sourceRepo = await sourceRepoAccessor.FetchRepository();

            // apply settings to repository
            sourceRepo.Settings = new Repositories.RepositorySettings()
            {
                Command = instance.Dto.Command,
                CommandArgs = instance.Dto.CommandArgs
            };

            // synchronize
            await RepositoryProcessor.Synchronize(sourceRepo, instance.Value);
        }