Пример #1
0
        public void Validate()
        {
            long i = 0;

            m_Status = "Validating";

            LoadLog();

            foreach (Fingerprint ManifestFingerprint in m_ManifestFileList)
            {
                if (Kill)
                {
                    return;
                }

                i++;
                m_current = ManifestFingerprint.FullName;

                ProgressEventArgs e = new ProgressEventArgs(i, m_ManifestFileList.Count);

                Fingerprint LocalFingerprint;
                if (ManifestFingerprint.Size == 0)
                {
                    // File is to be deleted
                    if (System.IO.File.Exists(ManifestFingerprint.FullName))
                    {
                        System.IO.File.Delete(ManifestFingerprint.FullName);
                    }
                }
                else if (System.IO.File.Exists(ManifestFingerprint.FullName))
                {
                    // File exists locally, lets start verifying it. First check if
                    // the checksum matches the one in our last run log, if so there
                    // is no need to download the file nor do a checksum
                    if (AlreadyVerified(ManifestFingerprint.FileName,
                                        ManifestFingerprint.Size,
                                        ManifestFingerprint.Checksum))
                    {
                        FlagVerified(ManifestFingerprint.FileName, ManifestFingerprint.Size, ManifestFingerprint.Checksum);
                    }
                    else
                    {
                        // Get an md5 checksum for the local copy of the file
                        LocalFingerprint = new Fingerprint(ManifestFingerprint.RootPath, ManifestFingerprint.FileName);

                        if (LocalFingerprint.Equals(ManifestFingerprint))
                        {
                            FlagVerified(ManifestFingerprint.FileName, ManifestFingerprint.Size, ManifestFingerprint.Checksum);
                        }
                        else
                        {
                            // There was no match, lets add the file to our download queue
                            AddToDownloadQueue(ManifestFingerprint);
                        }
                    }
                }
                else
                {
                    // File does not exist locally, we must download it. Add to our download queue.
                    AddToDownloadQueue(ManifestFingerprint);
                }
                m_progress = (int)(Math.Round((i / 100.0f) * 100.0f));
            }

            DownloadFiles();
        }