示例#1
0
        private void SyncEmptyFolders()
        {
            //read metadata of the current folder in file system
            FolderMetadata currentItems = MetaDataProvider.GenerateFolderMetadata(_job.SyncSource.Path, _job.SyncSource.ID, false, false, true);

            //read the folder metadata of current folder stored in database
            FolderMetadata oldCurrentItems = mdProvider.LoadFolderMetadata(_job.SyncSource.ID, SourceOption.SOURCE_ID_EQUALS);

            //read folder metadata of the other source stored in the database
            FolderMetadata otherItems = mdProvider.LoadFolderMetadata(_job.SyncSource.ID, SourceOption.SOURCE_ID_NOT_EQUALS);

            //get the difference between current folder metadata with its previous state (from previous sync session).
            FolderMetadataComparer comparer1 = new FolderMetadataComparer(oldCurrentItems, currentItems);

            //get the difference between current folder metadata with the other folder's previous metadata
            FolderMetadataComparer compare2 = new FolderMetadataComparer(currentItems, otherItems);


            FolderMetadataComparer comparer3 = new FolderMetadataComparer(oldCurrentItems.FolderMetadataItems, compare2.LeftOnly);
            FolderMetadataComparer comparer4 = new FolderMetadataComparer(compare2.RightOnly, comparer1.LeftOnly);

            List <FolderMetadataItem> temps = comparer3.Both.ToList();

            temps.Sort(new FolderMetadataItemComparer());
            temps.Reverse();

            foreach (FolderMetadataItem item in temps)
            {
                SyncExecutor.DeleteFolder(this._job.SyncSource.Path, item.RelativePath, true);
            }

            foreach (FolderMetadataItem item in comparer4.LeftOnly)
            {
                if (item.IsEmpty == 1)
                {
                    SyncExecutor.CreateFolder(this._job.SyncSource.Path, item.RelativePath);
                }
            }

            currentItems = MetaDataProvider.GenerateFolderMetadata(_job.SyncSource.Path, _job.SyncSource.ID, false,
                                                                   false, true);
            mdProvider.UpdateFolderMetadata(oldCurrentItems, currentItems, false);
        }
示例#2
0
        private void SyncEmptyFolders()
        {
            //read metadata of the current folder in file system
            FolderMetadata currentItems = MetaDataProvider.GenerateFolderMetadata(_job.SyncSource.Path, _job.SyncSource.ID, false,false,true);

            //read the folder metadata of current folder stored in database
            FolderMetadata oldCurrentItems = mdProvider.LoadFolderMetadata(_job.SyncSource.ID, SourceOption.SOURCE_ID_EQUALS);

            //read folder metadata of the other source stored in the database
            FolderMetadata otherItems = mdProvider.LoadFolderMetadata(_job.SyncSource.ID, SourceOption.SOURCE_ID_NOT_EQUALS);

            //get the difference between current folder metadata with its previous state (from previous sync session).
            FolderMetadataComparer comparer1 = new FolderMetadataComparer(oldCurrentItems, currentItems);

            //get the difference between current folder metadata with the other folder's previous metadata
            FolderMetadataComparer compare2 = new FolderMetadataComparer(currentItems, otherItems);

            FolderMetadataComparer comparer3 = new FolderMetadataComparer(oldCurrentItems.FolderMetadataItems, compare2.LeftOnly);
            FolderMetadataComparer comparer4 = new FolderMetadataComparer(compare2.RightOnly, comparer1.LeftOnly);

            List<FolderMetadataItem> temps = comparer3.Both.ToList();

            temps.Sort(new FolderMetadataItemComparer());
            temps.Reverse();

            foreach (FolderMetadataItem item in temps)
                SyncExecutor.DeleteFolder(this._job.SyncSource.Path, item.RelativePath, true);

            foreach (FolderMetadataItem item in comparer4.LeftOnly)
                if (item.IsEmpty == 1) SyncExecutor.CreateFolder(this._job.SyncSource.Path, item.RelativePath);

            currentItems = MetaDataProvider.GenerateFolderMetadata(_job.SyncSource.Path, _job.SyncSource.ID, false,
                                                                   false, true);
            mdProvider.UpdateFolderMetadata(oldCurrentItems, currentItems, false);
        }