예제 #1
0
        public override List <IConflict> GetSlaveConflicts()
        {
            FileChecker      fileChecker      = new FileChecker(slavePath, masterPath);
            DirectoryChecker directoryChecker = new DirectoryChecker(masterPath);

            List <IConflict> conflicts = new List <IConflict>();

            storage.Push(slavePath);

            while (storage.Count != 0)
            {
                string current = storage.Pop();
                if (directoryChecker.GetTypeConflict(current.Replace(slavePath, "")) == DirectoryConflictType.NoExistConflict)
                {
                    conflicts.Add(new NoExistDirectoryConflict(masterPath + current.Replace(slavePath, "")));
                }

                var files = Directory.GetFiles(current).Select(x => x.Replace(slavePath, ""));

                foreach (var file in files)
                {
                    if (fileChecker.GetTypeConflict(file) == FileConflictType.NoExistConflict)
                    {
                        conflicts.Add(new NoExistFileConflict(slavePath + file, masterPath + file));
                    }
                }

                AddNewDirectories(current);
            }

            return(conflicts);
        }
예제 #2
0
        public List <IConflict> GetMasterConflict()
        {
            FileChecker      fileChecker      = new FileChecker(masterPath, slavePath);
            DirectoryChecker directoryChecker = new DirectoryChecker(slavePath);

            List <IConflict> conflicts = new List <IConflict>();

            storage.Push(masterPath);

            while (storage.Count != 0)
            {
                string current = storage.Pop();
                if (directoryChecker.GetTypeConflict(current.Replace(masterPath, "")) == DirectoryConflictType.NoExistConflict)
                {
                    conflicts.Add(new NoExistDirectoryConflict(slavePath + current.Replace(masterPath, "")));
                }

                var files = Directory.GetFiles(current).Select(x => x.Replace(masterPath, ""));

                foreach (var file in files)
                {
                    switch (fileChecker.GetTypeConflict(file))
                    {
                    case FileConflictType.NoExistConflict:
                        conflicts.Add(new NoExistFileConflict(masterPath + file, slavePath + file));
                        break;

                    case FileConflictType.DifferentContent:
                        conflicts.Add(new DifferentContentConflict(masterPath + file, slavePath + file));
                        break;
                    }
                }

                AddNewDirectories(current);
            }

            return(conflicts);
        }