aeat.adapters.outbound.storage._integrity module

Shared content-hash integrity verification for outbound storage backends.

Both adapters.outbound.storage._local.LocalFileSystemProvider and adapters.outbound.storage._google_drive.GoogleDriveProvider persist a content_hash (optionally sha256--prefixed) alongside each object and re-check it on read. This module centralises the strip_sha256_prefix() convention and the verify_content_hash() compare-and-raise kernel so the two backends share one integrity contract; each backend keeps its own message, context, and verification policy.

strip_sha256_prefix(stored_hash)[source]

Return the bare hex digest from a possibly sha256--prefixed stored hash.

Used by verify_content_hash() before comparing a stored provider digest with a caller-supplied core.hashing.sha256_hex() value.

Return type:

str

Parameters:

stored_hash (str)

verify_content_hash(actual_hash, stored_hash, *, message, context, translated_message, require_full_digest=False)[source]

Raise OutboundStorageIntegrityError when a stored hash disagrees.

A no-op when stored_hash is empty or carries no digest. With require_full_digest the check is skipped unless the stripped digest is a full 64-character hex string (adapters.outbound.storage._google_drive.GoogleDriveProvider policy); without it any non-empty stripped digest is compared against actual_hash (adapters.outbound.storage._local.LocalFileSystemProvider policy). actual_hash is supplied by the caller because the local backend reuses it to stamp the written sidecar.

Return type:

None

Parameters: