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'.
This commit is contained in:
OlalalaO
2024-04-03 09:15:40 +08:00
committed by GitHub
parent e1542939b3
commit de434ed179

View File

@@ -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()