From de434ed179a12e0187b688ff1eddf0883a7547e2 Mon Sep 17 00:00:00 2001 From: OlalalaO <46838921+OlalalalaO@users.noreply.github.com> Date: Wed, 3 Apr 2024 09:15:40 +0800 Subject: [PATCH] Fix download file error (#69) Fixed the error where the path does not exist when downloading files with paths like 'xxx/xxx/xxx/xxx.xx'. --- src/s3/client.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/s3/client.rs b/src/s3/client.rs index acebff5..e537c35 100644 --- a/src/s3/client.rs +++ b/src/s3/client.rs @@ -1515,7 +1515,12 @@ impl Client { unmodified_since: None, }) .await?; - + let path = Path::new(&args.filename); + if let Some(parent_dir) = path.parent() { + if !parent_dir.exists() { + fs::create_dir_all(parent_dir)?; + } + } let mut file = match args.overwrite { true => File::create(args.filename)?, false => File::options()