CmisSync.Lib.Utils.IsFileWorthSyncing C# (CSharp) Method

IsFileWorthSyncing() public static method

Check whether the file is worth syncing or not. This optionally excludes blank files or files too large.
public static IsFileWorthSyncing ( string filepath, RepoInfo repoInfo ) : bool
filepath string
repoInfo RepoInfo
return bool
        public static bool IsFileWorthSyncing(string filepath, RepoInfo repoInfo)
        {
            if (File.Exists(filepath))
            {
                bool allowBlankFiles = true; //TODO: add a preference repoInfo.allowBlankFiles
                bool limitFilesize = false; //TODO: add preference for filesize limiting
                long filesizeLimit = 256 * 1024 * 1024; //TODO: add a preference for filesize limit

                FileInfo fileInfo = new FileInfo(filepath);

                //Check permissions
                if (fileInfo.Attributes.HasFlag(FileAttributes.Hidden))

                {
                    Logger.InfoFormat("Skipping {0}: hidden file", filepath);
                    return false;
                }
                if (fileInfo.Attributes.HasFlag(FileAttributes.System))
                {
                    Logger.InfoFormat("Skipping {0}: system file", filepath);
                    return false;
                }

                //Check filesize
                if (!allowBlankFiles && fileInfo.Length <= 0)
                {
                    Logger.InfoFormat("Skipping {0}: blank file", filepath);
                    return false;
                }
                if (limitFilesize && fileInfo.Length > filesizeLimit)
                {
                    Logger.InfoFormat("Skipping {0}: file too large {1}MB", filepath, fileInfo.Length / (1024f * 1024f));
                    return false;
                }

            }
            else if (Directory.Exists(filepath))
            {
                return IsDirectoryWorthSyncing(filepath, repoInfo);
            }
            return true;
        }