Skip to content

Commit

Permalink
clean: handle subdirectories in pacman cache
Browse files Browse the repository at this point in the history
When running paru -Scc, ensure subdirectories in the pacman package cache
are properly removed using sudo. Use the cache directory from pacman's
configuration instead of hardcoding the path to respect user settings.

closes Morganamilo#1302
  • Loading branch information
Roman Stingler committed Dec 25, 2024
1 parent c9c4a23 commit b1632a7
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,23 @@ use tr::tr;

pub fn clean(config: &Config) -> Result<()> {
if config.mode.repo() {
if let Some(pkg_cache) = config.pacman.cache_dir.first() {
let pkg_cache = Path::new(pkg_cache);
if pkg_cache.exists() {
for entry in read_dir(pkg_cache)? {
let entry = entry?;
let path = entry.path();
if path.is_dir() {
let mut cmd = Command::new(&config.sudo_bin);
cmd.args(&config.sudo_flags)
.arg("rm")
.arg("-rf")
.arg(&path);
exec::command(&mut cmd)?;
}
}
}
}
exec::pacman(config, &config.args)?;
}

Expand Down

0 comments on commit b1632a7

Please sign in to comment.