pub async fn copy_object_with_fallback(
client: &Client,
src_bucket: &str,
src_key: &str,
dest_bucket: &str,
dest_key: &str,
options: &CopyOptions,
fallback_threshold_bytes: u64,
confirmed_token: Option<String>,
confirmation_cache: &ConfirmationCache,
profile: &str,
) -> Result<CopyOutcome, AppError>Expand description
Copy src_bucket/src_key to dest_bucket/dest_key with a cross-account fallback.
§Behaviour
- Attempt server-side
CopyObject. - On
AccessDenied(cross-account signal): a. HEAD the source to learncontent_length. b. Ifcontent_length <= fallback_threshold_bytes→ download + upload (fallback path). ReturnsCopyOutcome::FallbackUsed. c. Ifcontent_length > fallback_threshold_bytesandconfirmed_tokenis not a valid unconsumed token for this scope → returnAppError::Validationasking for explicit confirmation. d. Ifcontent_length > fallback_threshold_bytesandconfirmed_tokenis valid → fallback path proceeds. ReturnsCopyOutcome::FallbackUsed. - On any other error → propagate as-is.
§Confirmation token
The token must be minted by ConfirmationCache::mint with a matching
ConfirmScope and consumed here. The frontend obtains a token via the
cross_account_confirm command, then re-calls object_copy with the token.
§OCP
fallback_threshold_bytes is parameterised (driven by settings) so the
default can change without touching this function.