synology_apm_repo.sdk.format.chunkmap module

ChunkMapRecord — the 20-byte record describing one segment of a file’s content within a composition record (FORMAT-SPEC.md: ChunkMapRecord).

Every byte of every restorable unit is reached by walking an array of these; the ambiguity between the two record kinds (MAPPING/ZERO) is resolved once, here.

class synology_apm_repo.sdk.format.chunkmap.ChunkMapKind(*values)

Bases: Enum

Type (FORMAT-SPEC.md: ChunkMapRecord). Values match the on-disk encoding exactly — do not renumber.

MAPPING = 0
ZERO = 1
class synology_apm_repo.sdk.format.chunkmap.ChunkMapEntry(kind, file_offset, is_inherit, addr, map_num, repeat)

Bases: object

One decoded ChunkMapRecord.

map_num’s meaning depends on kind: for ChunkMapKind.MAPPING it is the address template length in chunks (the template repeats 1 + repeat times); for ChunkMapKind.ZERO it is the literal chunk count covered (repeat is always 0 there). Both come from bytes [16,20), split differently.

kind: ChunkMapKind
file_offset: int

fileChunkIdx << 12 — the byte offset within the described file where this record’s coverage begins.

is_inherit: bool

The INHERIT bit, purely descriptive (“carried over unchanged from a reference version”); reading never depends on it (FORMAT-SPEC.md: Hole vs. Zero vs. INHERIT).

addr: ChunkAddress | None

The chunk’s base address in Pool. None for ChunkMapKind.ZERO.

map_num: int
repeat: int
property length: int

Byte length this record covers, starting at file_offset.

property end_offset: int
synology_apm_repo.sdk.format.chunkmap.parse_chunk_map_record(data)

Decode one 20-byte ChunkMapRecord from the start of data (data may be longer; only the first 20 bytes are consulted).

A Mapping record’s embedded ChunkAddress is not range-checked (see ChunkAddress).

Raises:
synology_apm_repo.sdk.format.chunkmap.chunk_map_end_offset(page_bytes, index)

ChunkMapEntry.end_offset of record index in page_bytes, read without building the entry, for a binary search over a page.

Raises:
synology_apm_repo.sdk.format.chunkmap.iter_chunk_map_page(page_bytes, count)

Lazily decode count consecutive ChunkMapRecords starting at the front of page_bytes; the batch form of parse_chunk_map_record.

Raises: