private void WorkerIntegrityScanner_DoWork(object sender, DoWorkEventArgs e) { if (RunScan != null && RunScan.GetScanStatus() != ScanStatus.Finish) { bool paused = ShokoService.CmdProcessorHasher.Paused; ShokoService.CmdProcessorHasher.Paused = true; SVR_Scan s = RunScan; s.Status = (int)ScanStatus.Running; RepoFactory.Scan.Save(s); Refresh(); List <ScanFile> files = RepoFactory.ScanFile.GetWaiting(s.ScanID); int cnt = 0; foreach (ScanFile sf in files) { try { if (!File.Exists(sf.FullName)) { sf.Status = (int)ScanFileStatus.ErrorFileNotFound; } else { FileInfo f = new FileInfo(sf.FullName); if (sf.FileSize != f.Length) { sf.Status = (int)ScanFileStatus.ErrorInvalidSize; } else { ShokoService.CmdProcessorHasher.QueueState = new QueueStateStruct { queueState = QueueStateEnum.HashingFile, extraParams = new[] { sf.FullName } }; Hashes hashes = FileHashHelper.GetHashInfo(sf.FullName, true, OnHashProgress, false, false, false); if (string.IsNullOrEmpty(hashes.ED2K)) { sf.Status = (int)ScanFileStatus.ErrorMissingHash; } else { sf.HashResult = hashes.ED2K; if (!sf.Hash.Equals(sf.HashResult, StringComparison.InvariantCultureIgnoreCase)) { sf.Status = (int)ScanFileStatus.ErrorInvalidHash; } else { sf.Status = (int)ScanFileStatus.ProcessedOK; } } } } } catch (Exception) { sf.Status = (int)ScanFileStatus.ErrorIOError; } cnt++; sf.CheckDate = DateTime.Now; RepoFactory.ScanFile.Save(sf); if (sf.Status > (int)ScanFileStatus.ProcessedOK) { Instance.AddErrorScan(sf); } Refresh(); if (cancelIntegrityCheck) { break; } } if (files.Any(a => a.GetScanFileStatus() == ScanFileStatus.Waiting)) { s.Status = (int)ScanStatus.Standby; } else { s.Status = (int)ScanStatus.Finish; } RepoFactory.Scan.Save(s); Refresh(); RunScan = null; ShokoService.CmdProcessorHasher.Paused = paused; } }