This commit is contained in:
sagiferi
2026-01-11 17:57:37 +01:00
parent 02746cfd17
commit a31dc704fb
6 changed files with 166 additions and 7 deletions
+15 -6
View File
@@ -4,7 +4,7 @@ mod utils;
use models::CloudS3;
use std::fs;
use utils::{handle_bucket_contents, list_all_buckets};
use utils::{delete_old_files, handle_bucket_contents, list_all_buckets};
use crate::utils::s3_utils::{create_client, create_config};
@@ -12,14 +12,13 @@ use crate::utils::s3_utils::{create_client, create_config};
async fn main() {
// Választható: backup_config vagy clean_and_backup
// Jelenleg mindkettőt futtatjuk, ha létezik a fájl
if let Err(e) = run_clean_and_backup().await {
eprintln!("Hiba a clean_and_backup futtatásakor: {}", e);
}
if let Err(e) = run_backup_config().await {
eprintln!("Hiba a backup_config futtatásakor: {}", e);
}
if let Err(e) = run_clean_and_backup().await {
eprintln!("Hiba a clean_and_backup futtatásakor: {}", e);
}
}
/// Backup a backup_config.json alapján (eredeti működés)
@@ -80,7 +79,7 @@ async fn run_clean_and_backup() -> Result<(), Box<dyn std::error::Error>> {
let bucket_cloud = CloudS3 {
name: format!("{}/{}", cloud.name, bucket_name),
region: cloud.region.clone(),
bucket: bucket_name,
bucket: bucket_name.clone(),
accesskey: cloud.accesskey.clone(),
secretekey: cloud.secretekey.clone(),
endpoint_url: cloud.endpoint_url.clone(),
@@ -91,6 +90,16 @@ async fn run_clean_and_backup() -> Result<(), Box<dyn std::error::Error>> {
Ok(_) => (),
Err(e) => eprintln!("Hiba a bucket listázásakor: {}", e),
}
// 14 napnál régebbi fájlok törlése
match delete_old_files(&client, &bucket_cloud, 14).await {
Ok(count) => {
if count > 0 {
println!("{} régi fájl törölve a {} bucket-ből", count, bucket_name);
}
}
Err(e) => eprintln!("Hiba a régi fájlok törlésekor: {}", e),
}
}
}