1
Fork 0
mirror of https://github.com/redstrate/Auracite.git synced 2025-07-01 18:17:46 +00:00
auracite/src/downloader.rs

36 lines
849 B
Rust
Raw Normal View History

#[cfg(not(target_family = "wasm"))]
2024-09-29 17:45:53 -04:00
use downloader::{Download, Downloader};
use std::path::Path;
pub fn download(url: &str, path: &Path) -> Result<(), ()> {
#[cfg(target_family = "wasm")]
{
// TODO: Implement
Ok(())
}
#[cfg(not(target_family = "wasm"))]
{
let mut downloader = Downloader::builder().build().unwrap();
2024-09-29 17:45:53 -04:00
let mut dl = Download::new(url);
dl = dl.file_name(path);
2024-09-29 17:45:53 -04:00
if !path.exists() {
let result = downloader.download(&[dl]).unwrap();
2024-09-29 17:45:53 -04:00
for r in result {
return match r {
Err(e) => {
println!("Error: {}", e.to_string());
Err(())
}
Ok(s) => Ok(()),
};
}
2024-09-29 17:45:53 -04:00
}
Ok(())
}
2024-09-29 17:45:53 -04:00
}