Esempio n. 1
0
        /// <summary>
        /// fetch changes of files and subdirs for Two-Way sync recursively
        /// </summary>
        /// <param name="dirTree">dir tree</param>
        /// <param name="interruptChecker">is called when the cancellation or pause request should be checked in order to handel them</param>
        /// <param name="parentCompareResult">compare-result of parent | null in root</param>
        public static void FetchChangesInDirRecursively_TwoWay(DirTree dirTree, Func <bool> interruptChecker, TwoWayCompareResult parentCompareResult)
        {
            interruptChecker();

            TwoWayCompareResult result = parentCompareResult;

            foreach (DirTree childDir in dirTree.Dirs)
            {
                if (result == null)
                {
                    result = DetectDirChange_TwoWay(childDir.Info);
                }

                if (result != null)
                {
                    new SyncDirExecutionInfo(childDir.Info.SyncDirInfo, result.Direction, result.Remove);
                }

                FetchChangesInDirRecursively_TwoWay(childDir, interruptChecker, result);
            }

            foreach (MyFileInfo file in dirTree.Files)
            {
                if (result == null)
                {
                    DoFileComparison_TwoWay(file.SyncFileInfo, interruptChecker);
                }
                else
                {
                    file.Size = new Delimon.Win32.IO.FileInfo(result.Direction == SyncDirection.To2 ?
                                                              file.SyncFileInfo.AbsolutePath1 : file.SyncFileInfo.AbsolutePath2).Length; //load file size
                    new SyncFileExecutionInfo(file.SyncFileInfo, result.Direction, result.Remove);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// compare file in paths for two way synchronisation in new task
        /// </summary>
        /// <param name="fileName">filename</param>
        /// <param name="relativePath">file path relative to the homedir without filename</param>
        /// <param name="interruptChecker">is called when the cancellation or pause request should be checked in order to handel them</param>
        /// <returns>true if the operation was canceled</returns>
        public static bool DoFileComparison_TwoWay(SyncFileInfo file, Func <bool> interruptChecker)
        {
            if (interruptChecker())
            {
                return(true);
            }

            file.SyncStatus = SyncElementStatus.ChangeDetectingStarted;

            try
            {
                //compare
                TwoWayCompareResult compResult = Helper.CompareFiles_TwoWay(file);

                if (compResult == null)
                {
                    file.SyncStatus = SyncElementStatus.NoChangeFound;
                }
                else
                {
                    file.FileInfo.Size = new Delimon.Win32.IO.FileInfo(compResult.Direction == SyncDirection.To2 ?
                                                                       file.AbsolutePath1 : file.AbsolutePath2).Length; //load file size
                    new SyncFileExecutionInfo(file, compResult.Direction, compResult.Remove);
                }
            }
            catch (Exception e)
            {
                file.Conflicted(new FileConflictInfo(file, ConflictType.Unknown, 0, "RunTwoWayFileCompareTask", e.Message, e));
            }

            return(false);
        }
Esempio n. 3
0
        /// <summary>
        /// fetch changes of files and subdirs for Two-Way sync recursively
        /// </summary>
        /// <param name="dirTree">dir tree</param>
        /// <param name="interruptChecker">is called when the cancellation or pause request should be checked in order to handel them</param>
        /// <param name="parentCompareResult">compare-result of parent | null in root</param>
        public static void FetchChangesInDirRecursively_TwoWay(DirTree dirTree, Func<bool> interruptChecker, TwoWayCompareResult parentCompareResult)
        {
            interruptChecker();

            TwoWayCompareResult result = parentCompareResult;

            foreach (DirTree childDir in dirTree.Dirs)
            {
                if (result == null)
                    result = DetectDirChange_TwoWay(childDir.Info);

                if(result != null)
                    new SyncDirExecutionInfo(childDir.Info.SyncDirInfo, result.Direction, result.Remove);

                FetchChangesInDirRecursively_TwoWay(childDir, interruptChecker, result);
            }

            foreach (MyFileInfo file in dirTree.Files)
            {
                if(result == null)
                {
                    DoFileComparison_TwoWay(file.SyncFileInfo, interruptChecker);
                }
                else
                {
                    file.Size = new Delimon.Win32.IO.FileInfo(result.Direction == SyncDirection.To2 ?
                        file.SyncFileInfo.AbsolutePath1 : file.SyncFileInfo.AbsolutePath2).Length; //load file size
                    new SyncFileExecutionInfo(file.SyncFileInfo, result.Direction, result.Remove);
                }
            }
        }