Example #1
0
        public void Clear()
        {
            FileCheckedCount = 0;

            NewFiles.Clear();
            NewFilesForGroom.Clear();
            ChangedFiles.Clear();
            MissingFiles.Clear();
            LastModifiedDateFiles.Clear();
            ErrorFiles.Clear();
            IgnoredFiles.Clear();
            NewlyIgnoredFiles.Clear();
            IgnoredFilesForGroom.Clear();
            MovedFiles.Clear();
            MovedFileOrder.Clear();
            DuplicateFiles.Clear();
        }
Example #2
0
        protected void DoTrackMoves()
        {
            // For large number of moved files it's probably faster to
            // rebuild these lists from scratch than to remove many
            // individual items from them.
            List <ManifestFileInfo> missingFilesUpdated =
                new List <ManifestFileInfo>();

            List <ManifestFileInfo> newFilesUpdated =
                new List <ManifestFileInfo>();

            // Make files easy to find by their hashcodes
            HashFileDict missingFileDict = new HashFileDict();

            foreach (ManifestFileInfo missingFile in MissingFiles)
            {
                missingFileDict.Add(missingFile);
            }

            HashFileDict newFileDict = new HashFileDict();

            foreach (ManifestFileInfo newFile in NewFiles)
            {
                newFileDict.Add(newFile);
            }

            // Note which new files are really moved files for later when
            // we rebuild the new files list.
            HashSet <ManifestFileInfo> movedFiles =
                new HashSet <ManifestFileInfo>();

            foreach (ManifestFileInfo checkMissingFile in MissingFiles)
            {
                if (newFileDict.Dict.ContainsKey(checkMissingFile.FileHash))
                {
                    if (MovedFiles.ContainsKey(checkMissingFile.FileHash) == false)
                    {
                        MovedFiles.Add(
                            checkMissingFile.FileHash,
                            new MovedFileSet());

                        MovedFileOrder.Add(checkMissingFile.FileHash);
                    }

                    MovedFiles[checkMissingFile.FileHash].OldFiles.Add(checkMissingFile);

                    if (MovedFiles[checkMissingFile.FileHash].NewFiles.Count == 0)
                    {
                        // First time only
                        foreach (ManifestFileInfo nextNewFile in
                                 newFileDict.Dict[checkMissingFile.FileHash])
                        {
                            MovedFiles[checkMissingFile.FileHash].NewFiles.Add(nextNewFile);

                            // Remember for later rebuild
                            movedFiles.Add(nextNewFile);
                        }
                    }
                }
                else
                {
                    missingFilesUpdated.Add(checkMissingFile);
                }
            }

            // Rebuild new file list
            NewFilesForGroom.Clear();
            foreach (ManifestFileInfo checkNewFile in NewFiles)
            {
                if (movedFiles.Contains(checkNewFile) == false)
                {
                    newFilesUpdated.Add(checkNewFile);

                    String checkNewFilePath =
                        Manifest.MakeNativePathString(checkNewFile);

                    if (checkNewFilePath != ManifestNativeFilePath)
                    {
                        NewFilesForGroom.Add(
                            new FileInfo(checkNewFilePath));
                    }
                }
            }

            // Replace with updated lists
            MissingFiles = missingFilesUpdated;
            NewFiles     = newFilesUpdated;
        }