Beispiel #1
0
        /// <summary>
        /// Removes a CASRecord
        /// </summary>
        /// <param name="record"></param>
        public bool Remove(CASRecord record, TACTRepo tactRepo = null)
        {
            if (record == null)
            {
                return(false);
            }

            if (_CKeyEntries.TryGetValue(record.CKey, out var entry))
            {
                _CKeyEntries.Remove(record.CKey);
                _EKeyEntries.Remove(entry.EKey);

                // propagate removal
                if (tactRepo != null)
                {
                    tactRepo.IndexContainer?.Remove(entry.EKey);
                    tactRepo.DownloadFile?.Remove(entry.EKey);
                    tactRepo.DownloadSizeFile?.Remove(entry.EKey);
                }

                return(true);
            }

            return(false);
        }
Beispiel #2
0
 /// <summary>
 /// Removes a CASRecord
 /// </summary>
 /// <param name="record"></param>
 public void Remove(CASRecord record)
 {
     if (_CKeyEntries.TryGetValue(record.CKey, out var cKeyEntry))
     {
         Remove(cKeyEntry);
     }
     if (_EKeyEntries.TryGetValue(record.CKey, out var eKeyEntry))
     {
         Remove(eKeyEntry);
     }
 }
Beispiel #3
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;
        }