Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

625 B
Raw Blame
use anyhow::Context;
use aws_sdk_s3::{self as s3};

/// Checks if a given key exists in the bucket
#[tracing::instrument(skip(client), err)]
pub(in crate::service::s3) async fn exists(
    client: &s3::Client,
    bucket: &str,
    key: &str,
) -> anyhow::Result<bool> {
    let resp = client.head_object().bucket(bucket).key(key).send().await;

    match resp {
        Ok(_) => Ok(true),
        Err(e) => {
            if e.as_service_error().map(|e| e.is_not_found()) == Some(true) {
                return Ok(false);
            }

            Err(e).context("failed to perform head object operation")
        }
    }
}