download works
This commit is contained in:
@@ -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)?;
|
||||
|
||||
Reference in New Issue
Block a user