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

Method remove_old_repos

dev-scripts/src/sync/pkgsrc.rs:107–131  ·  view source on GitHub ↗

Remove all local repositories for packages that no longer exist in the official repositories. Get the list of all locally available pkgsrc repositories. If we find any that are not in the list of official packages, we remove them.

(&self, repos: &[String], download_dir: &Path)

Source from the content-addressed store, hash-verified

105 /// Get the list of all locally available pkgsrc repositories.
106 /// If we find any that are not in the list of official packages, we remove them.
107 fn remove_old_repos(&self, repos: &[String], download_dir: &Path) -> Result<(), Error> {
108 // First up, read the names of all repositories in the local download folder.
109 let local_repositories = filenames_in_dir(download_dir)?;
110
111 // Get the list of packages that no longer exist on the mirrors (and thereby archweb).
112 let remote_pkgs: HashSet<String> = HashSet::from_iter(repos.iter().map(String::from));
113
114 // Now remove all local repositories for which there's no longer an entry in the archweb
115 // response, as those packages are no longer served by the official mirrors.
116 let removed_pkgs: Vec<&String> = local_repositories.difference(&remote_pkgs).collect();
117
118 // Delete the repositories
119 if !removed_pkgs.is_empty() {
120 info!("Found {} repositories for cleanup:", removed_pkgs.len());
121 for removed in removed_pkgs {
122 remove_dir_all(download_dir.join(removed)).map_err(|source| Error::IoPath {
123 path: download_dir.join(removed),
124 context: "removing the file".to_string(),
125 source,
126 })?;
127 }
128 }
129
130 Ok(())
131 }
132
133 /// Update/clone all git repositories in parallel with rayon.
134 ///

Calls 3

filenames_in_dirFunction · 0.85
is_emptyMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected