diff options
| author | Mroik <mroik@delayed.space> | 2025-06-24 05:58:04 +0200 |
|---|---|---|
| committer | Mroik <mroik@delayed.space> | 2025-06-24 05:58:04 +0200 |
| commit | 8a996a3d7e6d119fa066d92dfdb9d75ad83d847c (patch) | |
| tree | d5f4ae8463ec2d0dfe18c62ad3fb28f072ab222e | |
| parent | 33faec5efb6a1ce649f594352421bac0d23a2f22 (diff) | |
Add support for multiple folders
| -rw-r--r-- | src/main.rs | 18 |
1 files changed, 14 insertions, 4 deletions
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<String> = 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<Vec<u8>> { +fn archive(location: &[String]) -> Result<Vec<u8>> { 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()?) } |
