예제 #1
0
        /// <summary>
        /// synchronise podcast media files
        /// </summary>
        /// <param name="controlFile">control file to use to control the process</param>
        /// <param name="whatIf">true to generate the status messages but not to actually perform the file copy / deletes</param>
        public void Synchronize(IReadOnlyControlFile controlFile, bool whatIf)
        {
            var filesToCopy = new List <FileSyncItem>();

            foreach (PodcastInfo podcast in controlFile.GetPodcasts())
            {
                string podcastSourcePath      = Path.Combine(controlFile.GetSourceRoot(), podcast.Folder);
                string podcastDestinationPath = Path.Combine(controlFile.GetDestinationRoot(), podcast.Folder);

                IList <IFileInfo> podcastSourceFiles = FileFinder.GetFiles(
                    podcastSourcePath,
                    podcast.Pattern.Value,
                    podcast.MaximumNumberOfFiles.Value,
                    podcast.SortField.Value,
                    podcast.AscendingSort.Value);

                FileRemover.RemoveUnwantedFiles(podcastSourceFiles, podcastDestinationPath, podcast.Pattern.Value, whatIf);

                IEnumerable <FileSyncItem> podcastSyncItems = podcastSourceFiles.Select(p => new FileSyncItem {
                    Source = p
                });

                filesToCopy.AddRange(podcastSyncItems);
            }

            FileCopier.CopyFilesToTarget(
                filesToCopy,
                controlFile.GetSourceRoot(),
                controlFile.GetDestinationRoot(),
                controlFile.GetFreeSpaceToLeaveOnDestination(),
                whatIf);

            foreach (PodcastInfo podcast in controlFile.GetPodcasts())
            {
                if (podcast.DeleteEmptyFolder.Value)
                {
                    string podcastDestinationPath = Path.Combine(controlFile.GetDestinationRoot(), podcast.Folder);
                    FolderRemover.RemoveFolderIfEmpty(podcastDestinationPath, whatIf);
                }
            }
        }
예제 #2
0
 protected override void When()
 {
     FileCopier.CopyFilesToTarget(SourceFiles, SourcePath, DestinationePath, 1000, false);
 }