MCPcopy Create free account
hub / github.com/archlinux/alpm / parallel_extract_files

Method parallel_extract_files

dev-scripts/src/sync/aur.rs:90–146  ·  view source on GitHub ↗

Extract .SRCINFO and PKGBUILD files from aur.git branches.

(&self)

Source from the content-addressed store, hash-verified

88
89 /// Extract .SRCINFO and PKGBUILD files from aur.git branches.
90 fn parallel_extract_files(&self) -> Result<(), Error> {
91 let packages: Vec<String> = get_packages_list()?;
92
93 let progress_bar = get_progress_bar(packages.len() as u64);
94
95 create_dir_all(self.target_dir()).map_err(|source| Error::IoPath {
96 path: self.download_dir(),
97 context: "recursively creating the directory".to_string(),
98 source,
99 })?;
100
101 let results: Vec<Result<(), Error>> = packages
102 .par_iter()
103 .map(|pkg| {
104 let pkg_dir = self.target_dir().join(pkg);
105 create_dir_all(&pkg_dir).map_err(|source| Error::IoPath {
106 path: pkg_dir.clone(),
107 context: "recursively creating the directory".to_string(),
108 source,
109 })?;
110
111 for file_type in [SRCINFO_FILE_NAME, PKGBUILD_FILE_NAME] {
112 let out_file =
113 File::create(pkg_dir.join(file_type)).map_err(|source| Error::IoPath {
114 path: pkg_dir.join(file_type),
115 context: "recursively creating the directory".to_string(),
116 source,
117 })?;
118 let output = Command::new("git")
119 .arg("show")
120 .arg(format!("{pkg}:{file_type}"))
121 .current_dir(self.repo_dir())
122 .stdout(Stdio::from(out_file))
123 .output()
124 .map_err(|source| Error::Io {
125 context: format!("extracting {file_type:?} from AUR repo {pkg:?}"),
126 source,
127 })?;
128 ensure_success(
129 &output,
130 format!("Extracting {file_type:?} from AUR repo {pkg:?}"),
131 )?;
132 }
133 progress_bar.inc(1);
134 Ok(())
135 })
136 .collect();
137
138 progress_bar.finish_with_message("All files extracted.");
139
140 // Log all errors during parallel extraction.
141 for error in results.into_iter().filter_map(Result::err) {
142 error!("{error:?}");
143 }
144
145 Ok(())
146 }
147

Callers 1

download_packagesMethod · 0.80

Calls 10

get_packages_listFunction · 0.85
get_progress_barFunction · 0.85
ensure_successFunction · 0.85
target_dirMethod · 0.80
download_dirMethod · 0.80
repo_dirMethod · 0.80
createFunction · 0.50
lenMethod · 0.45
joinMethod · 0.45
into_iterMethod · 0.45

Tested by

no test coverage detected