synology_apm_repo.sdk.units.content.pcps_disk module

VirtualDiskContentSource reassembles a PC/PS physical disk’s per-region dedup objects (“fragments”, FORMAT-SPEC.md: PC/PS disk fragments) into one ContentSource that behaves like a single disk image.

Two facts it depends on: a fragment’s chunk-map offsets are disk-absolute, so its DedupFile opened with the whole disk’s size is already a correctly-sparse whole-disk view; and db/file_meta.file_size is the whole disk’s capacity, not one fragment’s length (that comes from CompositionRecord.extent).

class synology_apm_repo.sdk.units.content.pcps_disk.DiskFragment(fid, start, end, dedup_file, src_file_path)

Bases: object

One PC/PS per-region object, resolved to a ready-to-read DedupFile and the disk-absolute [start, end) its composition covers (CompositionRecord.extent).

fid: int
start: int
end: int
dedup_file: DedupFile
src_file_path: str

For diagnostics only, never for addressing.

class synology_apm_repo.sdk.units.content.pcps_disk.VirtualDiskContentSource(size, fragments)

Bases: object

A PC/PS physical disk’s fragments as one ContentSource spanning [0, size).

Fragments overlap in real data: a fragment’s composition covers whole 4096-byte chunks, so the chunk straddling a region boundary can hold real data in the later region while the earlier one pads it with a ZERO declaration. Where more than one fragment covers a byte, the one with the higher start wins. The disk is split once into disjoint winning segments (_winning_segments) that read and export_range both use, so neither depends on write order.

async read(offset=0, length=None)

ContentSource.read; a request past size is clamped.

stream(block=8388608)
async export_range(writer, start, end, *, sparse=True, progress=None, tuning=None)

Exports the disk’s [start, end) into writer at offsets relative to start, one winning segment at a time, so overlaps are neither written nor counted twice. Gaps between fragments are holes: left unwritten when sparse=True and the writer allows it, zero-filled otherwise.

Raises:

ValueError – The range is not inside the disk.

pool_descriptor()

How a worker process rebuilds the fragments’ Pool: None unless every fragment’s file is backed by the same rebuildable one.

async planned_bytes(start, end)