Example #1
0
        public FilterResult Filter(
            IFileResource sourceResource,
            IEnumerable <IFileResource> targetResources,
            ITargetHistoryRepository targetHistoryRepository,
            IFileSystem source,
            IFileSystem target)
        {
            var primaryAncestor = FindPrimaryAncestorFolder(
                sourceResource.RelativePath
                );
            var shouldRecordOnly =
                ResourceExistsAtTarget(targetResources, sourceResource) ||
                ResourceExistsInHistory(targetHistoryRepository, sourceResource);

            if (shouldRecordOnly)
            {
                return(FilterResult.RecordOnly);
            }

            var shouldInclude =
                target.IsDirectory(primaryAncestor) ||
                RelativeBaseExistsInHistory(targetHistoryRepository, primaryAncestor);

            return(shouldInclude
                       ? FilterResult.Include
                       : FilterResult.Exclude);
        }
Example #2
0
        public FilterResult Filter(
            IFileResource sourceResource,
            IEnumerable <IFileResource> targetResources,
            ITargetHistoryRepository targetHistoryRepository,
            IFileSystem source,
            IFileSystem target)
        {
            return(HaveMatchingTargetResource() ||
                   HaveMatchingHistoryItem()
                       ? FilterResult.Ambivalent
                       : FilterResult.Include);

            bool HaveMatchingTargetResource()
            {
                var existing = targetResources.FirstOrDefault(
                    r => r.RelativePath == sourceResource.RelativePath
                    );

                return(existing?.Size == sourceResource.Size);
            }

            bool HaveMatchingHistoryItem()
            {
                var historyItem = targetHistoryRepository.Find(
                    sourceResource.RelativePath
                    );

                return(historyItem?.Size == sourceResource.Size);
            }
        }
Example #3
0
 private static bool RelativeBaseExistsInHistory(
     ITargetHistoryRepository targetHistoryRepository,
     string relativeBase)
 {
     return(targetHistoryRepository.FindAll(
                $"{relativeBase}/*"
                )
            .Any());
 }
Example #4
0
 public FilterResult Filter(IFileResource sourceResource,
                            IEnumerable <IFileResource> targetResources,
                            ITargetHistoryRepository targetHistoryRepository,
                            IFileSystem source,
                            IFileSystem target)
 {
     return(sourceResource.Name.StartsWith(".")
                ? FilterResult.Exclude
                : FilterResult.Ambivalent);
 }
Example #5
0
 private static bool ResourceExistsInHistory(
     ITargetHistoryRepository targetHistoryRepository,
     IFileResource sourceResource)
 {
     return(targetHistoryRepository.Find(
                sourceResource.RelativePath
                )
            ?.Size ==
            sourceResource.Size);
 }
        private bool HistoryFileExists(
            ITargetHistoryRepository targetHistoryRepository,
            IFileResource sourceResource)
        {
            var existing = targetHistoryRepository.Find(
                sourceResource.RelativePath
                );

            return(existing?.Size == sourceResource.Size);
        }
Example #7
0
 public FilterResult Filter(
     IFileResource sourceResource,
     IEnumerable <IFileResource> targetResources,
     ITargetHistoryRepository targetHistoryRepository,
     IFileSystem source,
     IFileSystem target)
 {
     return(_archiveFiles.Contains(sourceResource.RelativePath)
                ? FilterResult.Include
                : FilterResult.Exclude);
 }
Example #8
0
 public FilterResult Filter(
     IFileResource sourceResource,
     IEnumerable <IFileResource> targetResources,
     ITargetHistoryRepository targetHistoryRepository,
     IFileSystem source,
     IFileSystem target)
 {
     return(_filter(
                sourceResource,
                targetResources,
                targetHistoryRepository,
                source,
                target));
 }
        public FilterResult Filter(IFileResource sourceResource,
                                   IEnumerable <IFileResource> targetResources,
                                   ITargetHistoryRepository targetHistoryRepository,
                                   IFileSystem source,
                                   IFileSystem target)
        {
            var shouldExclude =
                TargetFileExists(targetResources, sourceResource) ||
                HistoryFileExists(targetHistoryRepository, sourceResource);

            return(shouldExclude
                       ? FilterResult.Exclude
                       : FilterResult.Ambivalent);
        }
Example #10
0
 public Synchronizer(
     ITargetHistoryRepository targetHistoryRepository,
     IResumeStrategy resumeStrategy,
     IPassThrough[] intermediatePipes,
     IFilter[] filters,
     IProgressReporter progressReporter,
     IOptions options)
 {
     ValidateIntermediatePipes(intermediatePipes);
     _targetHistoryRepository = targetHistoryRepository;
     _resumeStrategy          = resumeStrategy;
     _intermediatePipes       = intermediatePipes;
     _notifiables             = intermediatePipes
                                .OfType <ISyncQueueNotifiable>()
                                .ToArray();
     _filters          = filters;
     _progressReporter = progressReporter;
     _options          = options;
 }
 public TestArena()
 {
     _folder     = new AutoTempFolder();
     _dbDatabase = new SqLiteDatabase(_folder.Path);
     SUT         = Create(_folder);
 }
 public SiteSettingsServices(IPasswordHistoryRepository passwordHistoryRepository, ITargetHistoryRepository targetHistoryRepository, UserServices userServices)
 {
     _passwordHistoryRepository = passwordHistoryRepository;
     _targetHistoryRepository = targetHistoryRepository;
     _userServices = userServices;
 }