Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var settings = new ArgumentParser().Read(args);

            if (!Directory.Exists(settings.BasePath))
            {
                ShowPathMessage(settings.BasePath);
                return;
            }

            var log = new StupidLogger(settings.LogPath);
            var root_path = new DirectoryInfo(settings.BasePath);
            var counter = new Counter();

            SyncroniseDependencies(log, settings, root_path, counter);

            Console.WriteLine(counter);
        }
Ejemplo n.º 2
0
        static void SyncroniseDependencies(StupidLogger log, ArgumentParser settings, DirectoryInfo root_path, Counter counter)
        {
            var masters = FindMasters(settings.Masters, root_path);
            var src_files = FindMatches(settings.SourcePattern, root_path);
            var dst_files = FindMatches(settings.DestPattern, root_path);

            foreach (var filename in dst_files.Keys)
            {
                var match_list = dst_files[filename];
                if (match_list == null || match_list.Count < 1) continue;

                if (HasNoSource(log, counter, dst_files, filename, src_files)) continue;

                var newest_source = masters.Of(filename) ?? newest(src_files[filename]);
                if (settings.Verbose) log.Write("Chose: "+newest_source.FullName);

                UpdateDestinations(log, counter, newest_source, match_list);
            }
        }