Beispiel #1
0
        public void TestMasks()
        {
            var fileList = new FileMaskList();

            fileList.SetList(new List <string> {
                "*.txt", "/var", "dist", "!/var/log", "start*end.cpp"
            });

            // txt
            Assert.True(fileList.IsMatch("test.txt"));
            Assert.True(fileList.IsMatch("home/test.txt"));
            Assert.False(fileList.IsMatch("test.txt1"));

            // var
            Assert.True(fileList.IsMatch("var/www"));
            Assert.False(fileList.IsMatch("www/var"));

            // dist
            Assert.True(fileList.IsMatch("home/www/dist"));
            Assert.True(fileList.IsMatch("dist"));
            Assert.False(fileList.IsMatch("distX"));

            // negative
            Assert.False(fileList.IsMatch("var/log"));
            Assert.True(fileList.IsMatch("var/log1"));
            Assert.False(fileList.IsMatch("var/log/test"));

            // wildcard
            Assert.True(fileList.IsMatch("start_middle_end.cpp"));
            Assert.False(fileList.IsMatch("start_middle.cpp"));
        }
Beispiel #2
0
        public Sender(SyncOptions syncOptions, ILogger logger)
        {
            _logger                  = logger;
            _pathScanner             = new PathScanner(this);
            _sentReporter            = new SentReporter(_logger);
            _srcPath                 = Path.GetFullPath(syncOptions.SourcePath);
            _cancellationTokenSource = new CancellationTokenSource();

            if (!Directory.Exists(_srcPath))
            {
                throw new SyncException($"Invalid source path: {_srcPath}");
            }

            _excludeList = new FileMaskList();
            _excludeList.SetList(syncOptions.ExcludeList);

            _changes      = new Dictionary <string, FsSenderChange>();
            _needToScan   = true;
            _agentStarter = AgentStarter.Create(syncOptions, _logger);
            _logger.Log($"Sync {syncOptions}");
            _applyRequest = new ApplyRequest(_logger)
            {
                BasePath = _srcPath,
            };
            UpdateHasWork();
        }
Beispiel #3
0
 public void Setup()
 {
     _fileList = new FileMaskList();
     _fileList.SetList(new List <string>
     {
         "*.txt",
         "/var",
         "dist",
         "!/var/log",
         "start*end.cpp",
         "~*",
         "*.tmp",
         "*.pyc",
         "*.swp",
         ".git",
         "CVS",
     });
 }