mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-06-07 03:06:37 +00:00
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:
parent
44ac63ce0d
commit
9c7da6a179
10 changed files with 366 additions and 84 deletions
|
@ -12,7 +12,7 @@ use tokio::{
|
|||
sync::mpsc,
|
||||
};
|
||||
|
||||
use super::DownloadError;
|
||||
use super::{DownloadError, ExtractedFiles};
|
||||
use crate::utils::asyncify;
|
||||
|
||||
#[derive(Debug, ThisError)]
|
||||
|
@ -38,6 +38,7 @@ pub(super) async fn extract_zip_entry<R>(
|
|||
zip_reader: &mut ZipFileReader<Reading<'_, Take<R>>>,
|
||||
path: &Path,
|
||||
buf: &mut BytesMut,
|
||||
extracted_files: &mut ExtractedFiles,
|
||||
) -> Result<(), DownloadError>
|
||||
where
|
||||
R: AsyncRead + Unpin + Send + Sync,
|
||||
|
@ -48,7 +49,7 @@ where
|
|||
.ok_or_else(|| ZipError(ZipErrorInner::InvalidFilePath(raw_filename.into())))?;
|
||||
|
||||
// Calculates the outpath
|
||||
let outpath = path.join(filename);
|
||||
let outpath = path.join(&filename);
|
||||
|
||||
// Get permissions
|
||||
let mut perms = None;
|
||||
|
@ -64,6 +65,8 @@ where
|
|||
}
|
||||
|
||||
if raw_filename.ends_with('/') {
|
||||
extracted_files.add_dir(&filename);
|
||||
|
||||
// This entry is a dir.
|
||||
asyncify(move || {
|
||||
std::fs::create_dir_all(&outpath)?;
|
||||
|
@ -75,6 +78,8 @@ where
|
|||
})
|
||||
.await?;
|
||||
} else {
|
||||
extracted_files.add_file(&filename);
|
||||
|
||||
// Use channel size = 5 to minimize the waiting time in the extraction task
|
||||
let (tx, mut rx) = mpsc::channel::<Bytes>(5);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue