/// <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 - overwrite existing var cKeyEntry = new EncodingContentEntry { CKey = record.CKey, DecompressedSize = record.EBlock.DecompressedSize }; cKeyEntry.EKey = record.EKey; _CKeyEntries[record.CKey] = cKeyEntry; // EKeyPageTable - overwrite existing // get or add to the ESpecStringTable int especIndex = ESpecStringTable.IndexOf(record.ESpec); if (especIndex == -1) { especIndex = ESpecStringTable.Count - 2; ESpecStringTable.Insert(especIndex, record.ESpec); } // create the entry var eKeyEntry = new EncodingEncodedEntry() { CompressedSize = record.EBlock.CompressedSize, EKey = record.EKey, ESpecIndex = (uint)especIndex }; _EKeyEntries[record.EKey] = eKeyEntry; }
/// <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); } }
/// <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; }
/// <summary> /// Gets a CKeyEntry by it's Content Key /// </summary> /// <param name="ckey"></param> /// <param name="entry"></param> /// <returns></returns> public bool TryGetCKeyEntry(MD5Hash ckey, out EncodingContentEntry entry) => _CKeyEntries.TryGetValue(ckey, out entry);
public void Remove(EncodingContentEntry entry) { _CKeyEntries.Remove(entry.CKey); }
public void AddOrUpdate(EncodingContentEntry entry) { entry.Validate(); _CKeyEntries[entry.CKey] = entry; }
/// <summary> /// Removes a Content Entry /// <para>Note: CKeys and EKeys must have a 1:1 relationship</para> /// </summary> /// <param name="entry"></param> /// <returns></returns> public bool Remove(EncodingContentEntry entry) { return(entry == null || _CKeyEntries.Remove(entry.CKey)); }