From 8a996a3d7e6d119fa066d92dfdb9d75ad83d847c Mon Sep 17 00:00:00 2001 From: Mroik Date: Tue, 24 Jun 2025 05:58:04 +0200 Subject: Add support for multiple folders --- src/main.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 76172ab..56e20d9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ use std::{ + env::var, fs::File, io::Cursor, time::{Duration, UNIX_EPOCH}, @@ -18,8 +19,15 @@ const MAX_FILE_SIZE: usize = 50000000; #[tokio::main] async fn main() -> Result<()> { - let chat_id = std::env::var("CHAT_ID").unwrap(); - let tar_data = archive("test")?; + let chat_id = var("CHAT_ID").unwrap(); + let locations: Vec = var("LOCATIONS") + .unwrap() + .trim() + .split(':') + .map(|s| s.to_string()) + .collect(); + + let tar_data = archive(&locations)?; let encrypted_tar = encrypt_data("pub.txt", tar_data)?; let bot = Bot::from_env(); @@ -54,9 +62,11 @@ async fn main() -> Result<()> { Ok(()) } -fn archive(location: &str) -> Result> { +fn archive(location: &[String]) -> Result> { let mut b = Builder::new(Vec::new()); - b.append_dir_all(location, location)?; + for loc in location { + b.append_dir_all(loc, loc)?; + } Ok(b.into_inner()?) } -- cgit v1.2.3