예제 #1
0
        /// <summary>
        /// Adds a CASRecord to the EncodingFile generating all required entries. This will overwrite existing entries
        /// </summary>
        /// <param name="record"></param>
        public void AddOrUpdate(CASRecord record, TACTRepo tactRepo = null)
        {
            // CKeyPageTable
            Remove(record, tactRepo);
            var cKeyEntry = new EncodingContentEntry
            {
                CKey             = record.CKey,
                EKeys            = new List <MD5Hash>(),
                DecompressedSize = record.EBlock.DecompressedSize,
            };

            cKeyEntry.EKeys.Add(record.EKey);
            _CKeyEntries.Add(record.CKey, cKeyEntry);

            // get or add to the ESpecStringTable
            int especIndex = ESpecStringTable.IndexOf(record.ESpec);

            if (especIndex == -1)
            {
                especIndex = ESpecStringTable.Count - 2;
                ESpecStringTable.Insert(especIndex, record.ESpec);
            }

            // EKeyPageTable
            var eKeyEntry = new EncodingEncodedEntry()
            {
                CompressedSize = record.EBlock.CompressedSize,
                EKey           = record.EKey,
                ESpecIndex     = (uint)especIndex
            };

            _EKeyEntries[record.EKey] = eKeyEntry;

            // propogate the new record
            if (tactRepo != null)
            {
                tactRepo.IndexContainer?.Enqueue(record);
                tactRepo.DownloadFile?.AddOrUpdate(record);
                tactRepo.DownloadSizeFile?.AddOrUpdate(record);
            }
        }
예제 #2
0
        /// <summary>
        /// Adds a CASRecord to the EncodingFile generating all required entries. This will overwrite existing entries
        /// </summary>
        /// <param name="record"></param>
        public void AddOrUpdate(CASRecord record)
        {
            // CKeyPageTable
            if (_CKeyEntries.TryGetValue(record.CKey, out var cKeyEntry))
            {
                _EKeyEntries.Remove(cKeyEntry.EKey);
                cKeyEntry.EKey = record.EKey;
            }
            else
            {
                cKeyEntry = new EncodingContentEntry
                {
                    CKey             = record.CKey,
                    EKey             = record.EKey,
                    DecompressedSize = record.EBlock.DecompressedSize,
                };

                _CKeyEntries.Add(record.CKey, cKeyEntry);
            }

            // get or add to the ESpecStringTable
            int especIndex = ESpecStringTable.IndexOf(record.ESpec);

            if (especIndex == -1)
            {
                especIndex = ESpecStringTable.Count - 2;
                ESpecStringTable.Insert(especIndex, record.ESpec);
            }

            // EKeyPageTable
            var eKeyEntry = new EncodingEncodedEntry()
            {
                CompressedSize = record.EBlock.CompressedSize,
                EKey           = record.EKey,
                ESpecIndex     = (uint)especIndex
            };

            _EKeyEntries[record.EKey] = eKeyEntry;
        }