Skip to main content

object_copy

Function object_copy 

Source
pub async fn object_copy(
    profile_id: ProfileId,
    source: ObjectRef,
    destination: ObjectRef,
    options: CopyOptions,
    confirmed_token: Option<String>,
    store: State<'_, ProfileStoreHandle>,
    pool: State<'_, S3ClientPoolHandle>,
    locks: State<'_, LockRegistryHandle>,
    cache: State<'_, CacheHandle>,
    confirm_cache: State<'_, ConfirmationCacheHandle>,
    channel: AppHandle,
) -> Result<CopyOutcome, AppError>
Expand description

Copy source to destination with automatic cross-account fallback.

  • Attempts server-side CopyObject first.
  • On AccessDenied (cross-account scenario):
    • If the source size is ≤ fallback_threshold_bytes (default 100 MiB), falls back to download+upload automatically.
    • If the source size is above the threshold and confirmed_token is a valid one-time token minted by cross_account_confirm, falls back.
    • Otherwise returns AppError::Validation asking the frontend to call cross_account_confirm first.
  • Returns CopyOutcome instead of CopyResult so the frontend can show a “Used fallback” indicator when the fallback path was taken.
  • Acquires scoped locks on source and destination prefixes before calling S3.
  • Invalidates destination prefix cache and emits objects:updated on success.
  • Both locks are released (success or failure) before returning.