public static void WriteConfig(ServerRepositoryConfig config, string configXmlFilename)
        {
            config.Repositories.Clear();
            config.RepositoriesList.AddRange(config.Repositories.Values);

            XmlConfigLoader.Write<ServerRepositoryConfig>(config, configXmlFilename);
        }
Ejemplo n.º 2
0
 public Session(TcpClient client, FooSyncEngine foo, ServerRepositoryConfig config, Dictionary<string, ICollection<string>> exceptions)
 {
     UseSSL = false; // default to false until this functionality actually works
     _client = client;
     _foo = foo;
     _config = config;
     _exceptions = exceptions;
 }
Ejemplo n.º 3
0
        private void ProcessArguments(ProgramArguments args)
        {
            _args = args;

            var fooOptions = new Options();

            if (_args.Flags.ContainsKey("casesensitive"))
            {
                fooOptions.CaseInsensitive = _args.Flags["casesensitive"];
            }
            else
            {
                //
                // default to case-sensitive on Unix
                //
                fooOptions.CaseInsensitive = !(Environment.OSVersion.Platform == PlatformID.Unix);
            }

            _listenPort = DefaultPort;
            if (_args.Options.ContainsKey("port"))
            {
                try
                {
                    _listenPort = int.Parse(_args.Options["port"]);
                }
                catch (FormatException)
                {
                    // keep default port
                }
            }

            var configPath = DefaultConfig;
            if (_args.Options.ContainsKey("config"))
            {
                configPath = _args.Options["config"];
            }

            try
            {
                string err = string.Empty;
                _config = ServerRepositoryConfigLoader.GetConfig(configPath, out err);

                if (_config == null)
                {
                    Trace.TraceError("Error loading FooSync daemon config: {0}", err);
                    throw new Exception(string.Format("Error loading FooSync daemon config: {0}", err));
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError("Error loading FooSync daemon config: {0}: {1}{2}", ex.GetType().Name, ex.Message, ex.StackTrace);
                throw;
            }

            _exceptions = new Dictionary<string, ICollection<string>>();

            foreach (var repo in _config.Repositories)
            {
                _exceptions.Add(repo.Key, FooSyncEngine.PrepareExceptions(repo.Value.IgnorePatterns));
            }

            _foo = new FooSyncEngine(fooOptions);
        }