Downloads all packages and signatures of a package repository to a local directory.
(
&self,
repo_name: &str,
file_source: String,
download_dest: &PathBuf,
)
| 282 | |
| 283 | /// Downloads all packages and signatures of a package repository to a local directory. |
| 284 | fn download_packages( |
| 285 | &self, |
| 286 | repo_name: &str, |
| 287 | file_source: String, |
| 288 | download_dest: &PathBuf, |
| 289 | ) -> Result<Vec<PathBuf>, Error> { |
| 290 | let mut cmd = Command::new("rsync"); |
| 291 | cmd.args([ |
| 292 | "--recursive", |
| 293 | "--perms", |
| 294 | "--times", |
| 295 | "--delete", |
| 296 | "--hard-links", |
| 297 | // Copy actual files instead of symlinks. |
| 298 | // Most symlinks point to files up the tree of where we're looking at, |
| 299 | // which is why normal symlinks would be invalid. |
| 300 | "--copy-links", |
| 301 | // Check for deletions once everything has been transferred |
| 302 | "--delete-after", |
| 303 | // Only overwrite updated files in the very end. |
| 304 | // This allows for a somewhat "atomic" update process. |
| 305 | "--delay-updates", |
| 306 | // Print structured change information to be parsed |
| 307 | "--itemize-changes", |
| 308 | ]); |
| 309 | |
| 310 | // Don't download any files related to repository sync databases. |
| 311 | for variation in [ |
| 312 | ".db", |
| 313 | ".db.sig", |
| 314 | ".db.tar.*", |
| 315 | ".db.tar.*.sig", |
| 316 | ".db.tar.*.old", |
| 317 | ".db.tar.*.old.sig", |
| 318 | ".links.tar.*", |
| 319 | ".links.tar.*.sig", |
| 320 | ".files", |
| 321 | ".files.sig", |
| 322 | ".files.tar.*", |
| 323 | ".files.tar.*.sig", |
| 324 | ".files.tar.*.old", |
| 325 | ".files.tar.*.old.sig", |
| 326 | ] { |
| 327 | cmd.arg(format!("--exclude={repo_name}{variation}")); |
| 328 | } |
| 329 | |
| 330 | trace!("Running command: {cmd:?}"); |
| 331 | let output = cmd |
| 332 | .arg(file_source) |
| 333 | .arg(download_dest) |
| 334 | .output() |
| 335 | .map_err(|source| Error::Io { |
| 336 | context: format!( |
| 337 | "syncing all package and signature files for repository {repo_name}" |
| 338 | ), |
| 339 | source, |
| 340 | })?; |
| 341 |
no test coverage detected