1use std::path::PathBuf;
2
3use lux_lib::{config::Config, operations::Download, rockspec::Rockspec};
4
5use miette::Result;
6
7use crate::unpack::UnpackRemote;
8
9pub async fn fetch_remote(data: UnpackRemote, config: Config) -> Result<()> {
10 let package_req = data.package_req;
11
12 let rockspec = Download::new(&package_req, &config)
13 .download_rockspec()
14 .await?
15 .rockspec;
16
17 let destination = data.destination.unwrap_or_else(|| {
18 PathBuf::from(format!("{}-{}", &rockspec.package(), &rockspec.version()))
19 });
20 lux_lib::operations::FetchSrc::new(destination.clone().as_path(), &rockspec, &config)
21 .fetch()
22 .await?;
23
24 Ok(())
25}