Beispiel #1
0
        public static List <string> InitLocalSha(bool earse = false)
        {
            List <string> needToCalculateSha = new List <string>();

            var filesIn115 = OneOneFiveService.Get115FilesModel();
            var localFiles = GetAllLocalAvs();

            if (filesIn115 != null && filesIn115.Any())
            {
                if (earse)
                {
                    ScanDataBaseManager.TruncateLocalShaMapping();
                }

                foreach (var localFile in localFiles)
                {
                    var matchedRecord = filesIn115.FirstOrDefault(x => x.n.Equals(localFile.Name, StringComparison.OrdinalIgnoreCase) && x.s == localFile.Length);

                    if (matchedRecord != null && !string.IsNullOrEmpty(matchedRecord.sha))
                    {
                        LocalShaMapping temp = new LocalShaMapping
                        {
                            FilePath   = localFile.Name,
                            FileFolder = Path.GetPathRoot(localFile.FullName),
                            FileSize   = localFile.Length,
                            Sha1       = matchedRecord.sha
                        };

                        ScanDataBaseManager.InsertLocalShaMapping(temp);
                    }
                    else
                    {
                        needToCalculateSha.Add(localFile.FullName);
                    }
                }
            }

            return(needToCalculateSha);
        }