download works

This commit is contained in:
2026-01-03 19:03:39 +01:00
parent da499c792f
commit 135df74b1b
5 changed files with 20 additions and 13 deletions
+8 -1
View File
@@ -9,6 +9,7 @@ pub fn create_directory_if_not_exists(folder_name: &str) -> std::io::Result<()>
}
pub fn create_file_if_not_exist_or_differ(
root_folder: &str,
bucket_item: &S3Item,
content: &[u8],
) -> std::io::Result<()> {
@@ -16,7 +17,9 @@ pub fn create_file_if_not_exist_or_differ(
use std::io::Write;
use std::path::Path;
let path = Path::new(bucket_item.key.as_str());
let path_str = format!("{}/{}", root_folder, bucket_item.key);
let path = Path::new(&path_str);
if path.exists()
&& bucket_item
@@ -26,6 +29,10 @@ pub fn create_file_if_not_exist_or_differ(
return Ok(());
}
if let Some(parent) = path.parent() {
fs::create_dir_all(parent)?;
}
// Ha a fájl nem létezik vagy a tartalom különbözik, írjuk a fájlt
let mut file = fs::File::create(path)?;
file.write_all(content)?;