public static Patch CreateFromSource(IBackupSource source) { return new Patch(source, new EmptyBackupChain ()) { RemovedFiles = new string[0], AddedOrChangedFiles = source.EnumerateFiles () }; }
public FilterBackupSource(IBackupSource source, Predicate<IBackupSourceFile> filter) { if (source == null) throw new ArgumentNullException("source"); if (filter == null) throw new ArgumentNullException("filter"); _filter = filter; _source = source; }
public static Patch Compare(IBackupSource source, IBackupChain target) { Trace.WriteLine("Comparing source to destination", "Patch"); var result = new Patch(source, target); var sourceFiles = source.EnumerateFiles ().ToArray (); result.RemovedFiles = target.GetFiles().Where(file => sourceFiles.All(a => a.RelativePath.ToLower() != file.ToLower())); result.AddedOrChangedFiles = sourceFiles.Where(a => !target.GetFiles().Select(m => m.ToLower()).Contains(a.RelativePath.ToLower()) || target.GetFileSize(a.RelativePath) != a.GetFileSize() || !HashMatches(target, a)).AsParallel ().ToArray (); return result; }
protected Patch(IBackupSource source, IBackupChain target) { Source = source; Target = target; }