/// <summary>
/// Check whether the directory is worth syncing or not.
/// Directories that are not worth syncing include ignored, system, and hidden folders.
/// </summary>
public static bool IsDirectoryWorthSyncing(string localDirectory, RepoInfo repoInfo)
{
if (!localDirectory.StartsWith(repoInfo.TargetDirectory))
{
Logger.WarnFormat("Local directory is outside repo target directory. local={0}, repo={1}", localDirectory, repoInfo.TargetDirectory);
return(false);
}
//Check for ignored path...
string path = localDirectory.Substring(repoInfo.TargetDirectory.Length).Replace("\\", "/");
if (repoInfo.isPathIgnored(path))
{
Logger.DebugFormat("Skipping {0}: hidden folder", localDirectory);
return(false);
}
//Check system/hidden
DirectoryInfo directoryInfo = new DirectoryInfo(localDirectory);
if (directoryInfo.Exists)
{
if (directoryInfo.Attributes.HasFlag(FileAttributes.Hidden))
{
Logger.DebugFormat("Skipping {0}: hidden folder", localDirectory);
return(false);
}
if (directoryInfo.Attributes.HasFlag(FileAttributes.System))
{
Logger.DebugFormat("Skipping {0}: system folder", localDirectory);
return(false);
}
}
return(true);
}