private bool ShouldSkip(string mode, FileSyncProvider provider, ApplyingChangeEventArgs args) { //the built-in directory system is lame, you can't just specify the name of the directory //this changes the behavior to do just that if (args.NewFileData != null && args.NewFileData.IsDirectory) { if (_currentGroup.ShouldSkipSubDirectory(args.NewFileData)) { _progress.WriteVerbose("{0} [{1}] Skipping Folder {2}", mode, _currentGroup.Name, GetPathFromArgs(args)); return(true); } return(false); } if (args.CurrentFileData != null && args.CurrentFileData.IsDirectory) { if (_currentGroup.ShouldSkipSubDirectory(args.CurrentFileData)) { _progress.WriteVerbose("{0} [{1}] Skipping Folder {2}", mode, _currentGroup.Name, GetPathFromArgs(args)); return(true); } return(false); } if (args.NewFileData != null) { if (_alreadyAccountedFor.Contains(args.NewFileData.RelativePath)) { _progress.WriteVerbose("[{0}] Skipping new file because it was already backed up by a previous group: {1}", _currentGroup.NewFileCount, GetPathFromArgs(args)); return(true); } if (_currentGroup.ShouldSkipFile(args.NewFileData.RelativePath)) { _progress.WriteVerbose("[{0}] Skipping new file: {1}", _currentGroup.Name, GetPathFromArgs(args)); return(true); } return(false); } if (args.CurrentFileData != null) { if (_alreadyAccountedFor.Contains(args.CurrentFileData.RelativePath)) { _progress.WriteVerbose("Skipping current file because it was already backed up by a previous group: " + args.CurrentFileData.RelativePath + " " + args.CurrentFileData.Name); return(true); } if (_currentGroup.ShouldSkipFile(args.CurrentFileData.RelativePath)) { _progress.WriteVerbose("Skipping current file: " + args.CurrentFileData.RelativePath + " " + args.CurrentFileData.Name); return(true); } } return(false); }
/* * private void OnDestinationPreviewChange(object provider, ApplyingChangeEventArgs args) * { * if(ShouldSkip("Preview", (FileSyncProvider)provider,args)) * { * args.SkipChange = true; * return; * } * if(args.CurrentFileData !=null) * { * _currentGroup.NetChangeInBytes -= args.CurrentFileData.Size; * //below, we'll add back the new size, giving us the correct net change * } * string rootDirectoryPath = ((FileSyncProvider)provider).RootDirectoryPath; * switch (args.ChangeType) * { * case ChangeType.Create: * _progress.WriteVerbose("[{0}] Preview Create {1}", _currentGroup.Name, args.Path); * _currentGroup.NewFileCount++; * _currentGroup.NetChangeInBytes += args.NewFileData.Size; * _alreadyAccountedFor.Add(args.NewFileData.RelativePath); * break; * case ChangeType.Update: * _progress.WriteVerbose("[{0}] Preview Update {1}", _currentGroup.Name, args.Path); * _currentGroup.UpdateFileCount++; * _currentGroup.NetChangeInBytes += args.NewFileData.Size; * _alreadyAccountedFor.Add(args.CurrentFileData.RelativePath); * break; * case ChangeType.Delete: * if (!_currentGroup.NormallyPropogateDeletions) * { * args.SkipChange = true; * _progress.WriteVerbose("[{0}] Because of group policy, would not propagate deletion of {1}", _currentGroup.Name, args.Path); * } * else * { * _progress.WriteVerbose("[{0}] Preview Delete {1}", _currentGroup.Name, args.Path); * _currentGroup.DeleteFileCount++; * } * break; * } * InvokeProgress(args); * }*/ private bool ShouldSkip(string mode, MirrorEventArgs args) { try { if (args.Situation == MirrorSituation.DirectoryMissing) { string reasonForSkiping; if (_currentGroup.ShouldSkipSubDirectory(args.Path, out reasonForSkiping)) { _progress.WriteVerbose("{0} [{1}] Skipping folder '{2}' because {3}", mode, _currentGroup.Name, args.Path, reasonForSkiping); return(true); } //TODO: what about if it is not missing, but should be removed ? return(false); } if (_alreadyAccountedFor.Contains(args.Path)) { _progress.WriteVerbose( "[{0}] Skipping '{1}' because it was already backed up by a previous group", _currentGroup.Name, args.Path); return(true); } string reasonForSkipping; if (_currentGroup.ShouldSkipFile(args.Path, out reasonForSkipping)) { _progress.WriteVerbose("[{0}] Skipping '{1}' because {2}", _currentGroup.Name, args.Path, reasonForSkipping); return(true); } } catch (Exception e) { _progress.WriteException(e); } return(false); }