Class: Legion::Extensions::MicrosoftTeams::LocalCache::SSTableReader

Inherits:
Object
  • Object
show all
Defined in:
lib/legion/extensions/microsoft_teams/local_cache/sstable_reader.rb

Overview

Pure Ruby LevelDB SSTable (.ldb) reader with Snappy decompression. Reads Chromium’s IndexedDB LevelDB files without native LevelDB bindings.

Constant Summary collapse

48
BLOCK_TRAILER_SIZE =
5
[0x57, 0xfb, 0x80, 0x8b, 0x24, 0x75, 0x47, 0xdb].pack('C*').freeze

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ SSTableReader

Returns a new instance of SSTableReader.



16
17
18
# File 'lib/legion/extensions/microsoft_teams/local_cache/sstable_reader.rb', line 16

def initialize(path)
  @data = File.binread(path)
end

Instance Method Details

#each_entryObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/legion/extensions/microsoft_teams/local_cache/sstable_reader.rb', line 20

def each_entry(&)
  return enum_for(:each_entry) unless block_given?

  footer = read_footer
  return unless footer

  index_block = read_block(footer[:index_offset], footer[:index_size])
  return unless index_block

  parse_block_entries(index_block) do |_key, handle_data|
    offset, size, = decode_block_handle_at(handle_data, 0)
    next unless offset && size

    data_block = read_block(offset, size)
    next unless data_block

    parse_block_entries(data_block, &)
  end
end