Return a list of files written to disk in binstalk_downloader::download::Download::and_extract (#856)

to avoid collecting extracted files from disk again in resolution stage.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2023-03-03 23:31:27 +11:00 committed by GitHub
parent 44ac63ce0d
commit 9c7da6a179
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 366 additions and 84 deletions

View file

@ -13,7 +13,7 @@ use url::Url;
use crate::{
errors::{BinstallError, InvalidPkgFmtError},
helpers::{
download::Download,
download::{Download, ExtractedFiles},
futures_resolver::FuturesResolver,
gh_api_client::{GhApiClient, GhReleaseArtifact, HasReleaseArtifact},
remote::Client,
@ -216,7 +216,7 @@ impl super::Fetcher for GhCrateMeta {
})
}
async fn fetch_and_extract(&self, dst: &Path) -> Result<(), BinstallError> {
async fn fetch_and_extract(&self, dst: &Path) -> Result<ExtractedFiles, BinstallError> {
let (url, pkg_fmt) = self.resolution.get().unwrap(); // find() is called first
debug!("Downloading package from: '{url}' dst:{dst:?} fmt:{pkg_fmt:?}");
Ok(Download::new(self.client.clone(), url.clone())

View file

@ -7,7 +7,10 @@ use url::Url;
use crate::{
errors::BinstallError,
helpers::{
download::Download, gh_api_client::GhApiClient, remote::Client, tasks::AutoAbortJoinHandle,
download::{Download, ExtractedFiles},
gh_api_client::GhApiClient,
remote::Client,
tasks::AutoAbortJoinHandle,
},
manifests::cargo_toml_binstall::{PkgFmt, PkgMeta},
};
@ -63,7 +66,7 @@ impl super::Fetcher for QuickInstall {
})
}
async fn fetch_and_extract(&self, dst: &Path) -> Result<(), BinstallError> {
async fn fetch_and_extract(&self, dst: &Path) -> Result<ExtractedFiles, BinstallError> {
let url = self.package_url();
debug!("Downloading package from: '{url}'");
Ok(Download::new(self.client.clone(), Url::parse(&url)?)