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

Method sync_remote_packages

dev-scripts/src/sync/mirror/mod.rs:167–281  ·  view source on GitHub ↗

Download all official repository packages and extract all files that're interesting to us. Specifically: - `.BUILDINFO` - `.MTREE` - `.PKGINFO` - `.INSTALL` (Optional)

(&self)

Source from the content-addressed store, hash-verified

165 /// - `.PKGINFO`
166 /// - `.INSTALL` (Optional)
167 pub fn sync_remote_packages(&self) -> Result<(), Error> {
168 let download_dir = self
169 .cache_dir
170 .as_ref()
171 .join(DOWNLOAD_DIR)
172 .join(PACKAGES_DIR);
173 let target_dir = self.cache_dir.as_ref().join(PACKAGES_DIR);
174
175 create_dir_all(&download_dir).map_err(|source| Error::IoPath {
176 path: download_dir.clone(),
177 context: "recursively creating the directory".to_string(),
178 source,
179 })?;
180
181 create_dir_all(&target_dir).map_err(|source| Error::IoPath {
182 path: target_dir.clone(),
183 context: "recursively creating the directory".to_string(),
184 source,
185 })?;
186
187 for repo in self.repositories.iter() {
188 let repo_name = repo.to_string();
189 info!("Downloading packages for repository {repo_name}");
190
191 let file_source = format!("rsync://{}/{repo_name}/os/x86_64/", self.mirror);
192 let download_dest = download_dir.join(&repo_name);
193 let changed = self.download_packages(&repo_name, file_source, &download_dest)?;
194
195 let packages: Vec<PathBuf> = if self.extract_all {
196 let files: Vec<_> = read_dir(&download_dest)
197 .map_err(|source| Error::IoPath {
198 path: download_dest.to_path_buf(),
199 context: "reading entries in directory".to_string(),
200 source,
201 })?
202 .map(|result| {
203 result.map_err(|source| Error::IoPath {
204 path: download_dest.to_path_buf(),
205 context: "reading a directory entry".to_string(),
206 source,
207 })
208 })
209 .collect::<Result<_, Error>>()?;
210 files
211 .into_iter()
212 .map(|entry| entry.path().to_owned())
213 .collect::<Vec<_>>()
214 } else {
215 changed
216 .into_iter()
217 .map(|pkg| download_dest.join(pkg))
218 .collect()
219 }
220 .into_iter()
221 // Filter out any dotfiles.
222 // Those might be temporary download artifacts from previous rsync runs.
223 .filter(|entry| {
224 if let Some(path) = entry.to_str() {

Callers 1

test_filesFunction · 0.80

Calls 11

get_progress_barFunction · 0.85
extract_pkg_filesFunction · 0.85
filenames_in_dirFunction · 0.85
joinMethod · 0.45
as_refMethod · 0.45
download_packagesMethod · 0.45
into_iterMethod · 0.45
to_path_bufMethod · 0.45
pathMethod · 0.45
lenMethod · 0.45
is_emptyMethod · 0.45

Tested by 1

test_filesFunction · 0.64