Example #1
0
        bool UpdateArchives()
        {
            List <ArchiveInfo> NewArchives = new List <ArchiveInfo>();

            // Find all the zipped binaries under this stream
            ConfigSection ProjectConfigSection = LatestProjectConfigFile.FindSection(SelectedProjectIdentifier);

            if (ProjectConfigSection != null)
            {
                // Legacy
                string LegacyEditorArchivePath = ProjectConfigSection.GetValue("ZippedBinariesPath", null);
                if (LegacyEditorArchivePath != null)
                {
                    NewArchives.Add(new ArchiveInfo("Editor", "Editor", LegacyEditorArchivePath, null));
                }

                // New style
                foreach (string ArchiveValue in ProjectConfigSection.GetValues("Archives", new string[0]))
                {
                    ArchiveInfo Archive;
                    if (ArchiveInfo.TryParseConfigEntry(ArchiveValue, out Archive))
                    {
                        NewArchives.Add(Archive);
                    }
                }

                // Make sure the zipped binaries path exists
                foreach (ArchiveInfo NewArchive in NewArchives)
                {
                    bool bExists;
                    if (!Perforce.FileExists(NewArchive.DepotPath, out bExists, LogWriter))
                    {
                        return(false);
                    }
                    if (bExists)
                    {
                        // Query all the changes to this file
                        List <PerforceFileChangeSummary> Changes;
                        if (!Perforce.FindFileChanges(NewArchive.DepotPath, 100, out Changes, LogWriter))
                        {
                            return(false);
                        }

                        // Build a new list of zipped binaries
                        foreach (PerforceFileChangeSummary Change in Changes)
                        {
                            if (Change.Action != "purge")
                            {
                                string[] Tokens = Change.Description.Split(' ');
                                if (Tokens[0].StartsWith("[CL") && Tokens[1].EndsWith("]"))
                                {
                                    int OriginalChangeNumber;
                                    if (int.TryParse(Tokens[1].Substring(0, Tokens[1].Length - 1), out OriginalChangeNumber) && !NewArchive.ChangeNumberToFileRevision.ContainsKey(OriginalChangeNumber))
                                    {
                                        NewArchive.ChangeNumberToFileRevision[OriginalChangeNumber] = String.Format("{0}#{1}", NewArchive.DepotPath, Change.Revision);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            // Check if the information has changed
            if (!Enumerable.SequenceEqual(Archives, NewArchives))
            {
                Archives          = NewArchives;
                AvailableArchives = Archives.Select(x => (IArchiveInfo)x).ToList();

                if (OnUpdateMetadata != null && Changes.Count > 0)
                {
                    OnUpdateMetadata();
                }
            }

            return(true);
        }