Created
August 24, 2019 01:33
-
-
Save rrichardson/d2221b3f904fe53bf650b880495ffa2f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let jobs = myvec | |
.into_iter() | |
.map(|url| { | |
// we use the end of the supplied URL to create the directory | |
let uri = url.parse::<Uri>().unwrap(); | |
let p = uri.path(); | |
let segments = p.split('/').collect::<Vec<_>>(); | |
let end = &segments[segments.len() - 4..]; | |
let fullpath = Path::new(&ctx.config.data_dir).join(end.join("/")); | |
std::fs::create_dir_all(fullpath.parent().unwrap()).unwrap(); | |
requests::fetch_to_disk(uri, fullpath) | |
}); | |
let fut = futures::stream::futures_unordered(jobs).collect(); | |
let _result = runtime.block_on(fut).unwrap(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment