lc/sync/
s3.rs

1//! S3 synchronization module (requires s3-sync feature)
2
3#[cfg(feature = "s3-sync")]
4use super::ConfigFile;
5#[cfg(feature = "s3-sync")]
6use anyhow::Result;
7
8/// Upload configuration files to S3 using specified provider
9#[cfg(feature = "s3-sync")]
10pub async fn upload_to_s3_provider(files: &[ConfigFile], provider: &str, encrypted: bool) -> Result<()> {
11    use super::providers::S3Provider;
12    
13    // Create S3 provider with the specified provider name
14    let s3_provider = S3Provider::new_with_provider(provider).await?;
15    
16    // Upload configs with correct encryption status
17    s3_provider.upload_configs(files, encrypted).await
18}
19
20/// Download configuration files from S3 using specified provider
21#[cfg(feature = "s3-sync")]
22pub async fn download_from_s3_provider(provider: &str, encrypted: bool) -> Result<Vec<ConfigFile>> {
23    use super::providers::S3Provider;
24    
25    // Create S3 provider with the specified provider name
26    let s3_provider = S3Provider::new_with_provider(provider).await?;
27    
28    // Download configs with correct encryption status
29    s3_provider.download_configs(encrypted).await
30}
31
32// Keep the old functions for backward compatibility (deprecated)
33#[cfg(feature = "s3-sync")]
34#[deprecated(note = "Use upload_to_s3_provider instead")]
35pub async fn upload_to_s3(files: &[ConfigFile]) -> Result<()> {
36    upload_to_s3_provider(files, "s3", false).await
37}
38
39#[cfg(feature = "s3-sync")]
40#[deprecated(note = "Use download_from_s3_provider instead")]
41pub async fn download_from_s3() -> Result<Vec<ConfigFile>> {
42    download_from_s3_provider("s3", false).await
43}