use std::path::Path;
use crate::WyrdClient;
use wyrd_spec::storage::DownloadPlan;
use super::{DownloadOutcome, DownloadVerification};
use crate::storage::download::single_get::write_response;
use crate::storage::{
DownloadProgressSink,
error::{StorageClientError, from_authenticated},
};
pub(crate) async fn download(
client: &WyrdClient,
plan: &DownloadPlan,
dest: &Path,
) -> Result<DownloadOutcome, StorageClientError> {
let response = client
.http
.request_raw(reqwest::Method::GET, &plan.get_url)
.await
.map_err(from_authenticated)?;
write_response(response, dest, None, None).await
}
pub(crate) async fn download_verified(
client: &WyrdClient,
plan: &DownloadPlan,
dest: &Path,
verification: DownloadVerification<'_>,
progress: &DownloadProgressSink,
) -> Result<DownloadOutcome, StorageClientError> {
let response = client
.http
.request_raw(reqwest::Method::GET, &plan.get_url)
.await
.map_err(from_authenticated)?;
write_response(response, dest, Some(verification), Some(progress)).await
}