Download all official repository file databases and unpack them. They contain the following files: - `desc` - `files`
(&self)
| 46 | /// - `desc` |
| 47 | /// - `files` |
| 48 | pub fn sync_remote_databases(&self) -> Result<(), Error> { |
| 49 | let download_dir = self |
| 50 | .cache_dir |
| 51 | .as_ref() |
| 52 | .join(DOWNLOAD_DIR) |
| 53 | .join(DATABASES_DIR); |
| 54 | let target_dir = self.cache_dir.as_ref().join(DATABASES_DIR); |
| 55 | |
| 56 | create_dir_all(&download_dir).map_err(|source| Error::IoPath { |
| 57 | path: download_dir.clone(), |
| 58 | context: "recursively creating the directory".to_string(), |
| 59 | source, |
| 60 | })?; |
| 61 | |
| 62 | create_dir_all(&target_dir).map_err(|source| Error::IoPath { |
| 63 | path: target_dir.clone(), |
| 64 | context: "recursively creating the directory".to_string(), |
| 65 | source, |
| 66 | })?; |
| 67 | |
| 68 | for repo in self.repositories.iter() { |
| 69 | let name = repo.to_string(); |
| 70 | info!("Downloading database for repository {name}"); |
| 71 | |
| 72 | let filename = format!("{name}.files"); |
| 73 | let file_source = format!("rsync://{}/{name}/os/x86_64/{filename}", self.mirror); |
| 74 | |
| 75 | let download_dest = download_dir.join(filename); |
| 76 | |
| 77 | // Download the db from the mirror |
| 78 | let mut db_sync_command = Command::new("rsync"); |
| 79 | db_sync_command |
| 80 | .args([ |
| 81 | "--recursive", |
| 82 | "--perms", |
| 83 | "--times", |
| 84 | // Report changes status |
| 85 | "--itemize-changes", |
| 86 | // Copy files instead of symlinks |
| 87 | // Symlinks may point to files up the tree of where we're looking at, |
| 88 | // which is why normal symlinks would be invalid. |
| 89 | "--copy-links", |
| 90 | ]) |
| 91 | .arg(file_source) |
| 92 | .arg(&download_dest); |
| 93 | |
| 94 | trace!("Running command: {db_sync_command:?}"); |
| 95 | let output = db_sync_command.output().map_err(|source| Error::Io { |
| 96 | context: format!("synchronizing repository database for {name}"), |
| 97 | source, |
| 98 | })?; |
| 99 | |
| 100 | ensure_success( |
| 101 | &output, |
| 102 | format!("synchronizing repository database for {name}"), |
| 103 | )?; |
| 104 | |
| 105 | trace!( |