コード例 #1
0
ファイル: Root.cs プロジェクト: boom8866/WoWToolCollection
        /// <summary>
        /// Diff the 2 root files.
        /// Completely taken from https://github.com/Marlamin/CASCToolHost/blob/master/CASCToolHost/Controllers/RootController.cs#L59
        /// </summary>
        /// <param name="oldRoot"></param>
        /// <param name="newRoot"></param>
        public static IEnumerable <RootEntry> DiffRoot(string oldRootHash, string newRootHash)
        {
            try
            {
                var oldRootStream = BuildMonitor.RequestCDN($"tpr/wow/data/{oldRootHash.Substring(0, 2)}/{oldRootHash.Substring(2, 2)}/{oldRootHash}");
                var newRootStream = BuildMonitor.RequestCDN($"tpr/wow/data/{newRootHash.Substring(0, 2)}/{newRootHash.Substring(2, 2)}/{newRootHash}");

                if (oldRootStream == null || newRootStream == null)
                {
                    return(new List <RootEntry>());
                }

                var rootFromEntries = ParseRoot(oldRootStream).FileDataIds;
                var rootToEntries   = ParseRoot(newRootStream).FileDataIds;

                var fromEntries = rootFromEntries.Keys.ToHashSet();
                var toEntries   = rootToEntries.Keys.ToHashSet();

                var commonEntries  = fromEntries.Intersect(toEntries);
                var removedEntries = fromEntries.Except(commonEntries);
                var addedEntries   = toEntries.Except(commonEntries);