synology_apm_repo.sdk.storage.layout module¶
Repository layout detection (FORMAT-SPEC.md: Locating the repository root).
Two shapes exist, both at a fixed depth:
Vault (APV, or any local-filesystem Copy destination): a directory (conventionally
@ActiveProtectVault; detection is by marker, not name) is the repository root, one level under the admin-chosen shared folder. Identified byrepo_info,link.keyand.fully_createdtogether at that path. One repository per root, one vault per shared folder.Object storage (S3/Azure landed copies): the root contains an
@ActiveProtectData/<12-char-repo-id>/subtree, possibly with several sibling<repo-id>directories, and a parallel@ActiveProtectKey/{userKey,link}/tree one level up from@ActiveProtectData. Each<repo-id>is an independent repository sharing the same key tree.repo_infois not a reliable marker there (it may exist only asrepo_info.<N>).db/and@dataare always bare-named directories, so the pair is the marker; requiring both guards against unrelated directories that merely containdb.
Neither shape nests more than one level under what an admin provisioned (a
shared folder, a bucket), so a connection pointed up to two levels above
that still finds every repository. _DEFAULT_MAX_DEPTH bounds the walk at
that, so a misdirected scan of an unrelated tree can’t run away.
- synology_apm_repo.sdk.storage.layout.REPO_INFO_NAME = 'repo_info'¶
The logical name of the repository-root
repo_infofile, as FORMAT-SPEC.md’s repo_info section defines it.
- class synology_apm_repo.sdk.storage.layout.RepoKind(*values)¶
Bases:
EnumWhich of the two physical repository backends a
RepoLayoutdescribes.- VAULT = 'vault'¶
- OBJECT_STORE = 'object_store'¶
- class synology_apm_repo.sdk.storage.layout.RepoLayout(kind, repo_root, key_root=None, repo_id=None)¶
Bases:
objectWhere one catalog (a vault, or one
<repo-id>directory) lives within anObjectStore: whatDedupRepo.open()takes. Built from aRepositoryLayoutbycatalog_repo_layouts.- Variables:
kind (synology_apm_repo.sdk.storage.layout.RepoKind) – Vault or object storage.
repo_root (str) – Store-relative repository root (
"": the store root).key_root (str | None) – Store-relative
@ActiveProtectKeydirectory for object storage, orNoneif not found or not applicable.repo_id (str | None) – The 12-character repository id for object storage, when known.
- class synology_apm_repo.sdk.storage.layout.RepositoryLayout(kind, repo_root, key_root=None, catalog_ids=None)¶
Bases:
objectWhere one Repository (a bucket, or a vault’s own shared folder) lives within an
ObjectStore.- Variables:
kind (synology_apm_repo.sdk.storage.layout.RepoKind) – Vault or object storage.
repo_root (str) – Store-relative root (
"": the store root).key_root (str | None) – Store-relative
@ActiveProtectKeydirectory, orNone.catalog_ids (list[str] | None) – For
OBJECT_STORE, the valid repo-id children of@ActiveProtectData/(an empty list: none).NoneforVAULT(catalogs come fromdb/connection_config) and whenrootis an individual repository directory with no derivable bucket-root ancestor (see_data_dir_ancestor).
- async synology_apm_repo.sdk.storage.layout.iter_repository_layouts(store, root='', *, max_depth=2)¶
Walk down from
rootlooking for Repository roots (a bucket, or a vault’s shared folder), yielding each as found. A bucket with several catalogs yields oneRepositoryLayoutwhosecatalog_idslists them.Only
exists()/listdir()calls, never a scan intoPool/Composition/db. A found root ends the walk along its branch; otherwisemax_depth(default 2, see the module docstring) bounds it.
- synology_apm_repo.sdk.storage.layout.catalog_repo_layouts(layout)¶
The
RepoLayout(s)layoutresolves to, each openable byDedupRepo.open().A vault, or an
OBJECT_STORElayout withcatalog_idsofNone, yields oneRepoLayoutatlayout.repo_root(a vault’s catalogs come fromdb/connection_configafter opening). Otherwise one percatalog_idsentry, rooted at its@ActiveProtectData/<repo-id>directory and sharinglayout.key_root. Empty only whencatalog_idsis an empty list.
- synology_apm_repo.sdk.storage.layout.key_probe_layout(layout)¶
A
RepoLayoutcarrying only the fieldsdedup.keysreads for key and encryption resolution (probe_encrypted/resolve_vault_key/verify), built from aRepositoryLayoutwithout opening a catalog. Used by discovery’s key probe andRepository.set_key().
- async synology_apm_repo.sdk.storage.layout.detect_repository_layout(store, root='')¶
Detect the Repository layout at
root. A bucket’s several repository ids are not an error; they appear incatalog_ids.- Raises:
NotFoundError –
rootis not a repository root.