Implement cleanup for flatpak (#801)
* Cleanup flatpak * Fix compile error * Make sure we only move our values at the very end * Access config.cleanup() through ExecutionContext
This commit is contained in:
@@ -450,6 +450,7 @@ pub fn run_fwupdmgr(ctx: &ExecutionContext) -> Result<()> {
|
|||||||
pub fn flatpak_update(ctx: &ExecutionContext) -> Result<()> {
|
pub fn flatpak_update(ctx: &ExecutionContext) -> Result<()> {
|
||||||
let flatpak = require("flatpak")?;
|
let flatpak = require("flatpak")?;
|
||||||
let sudo = require_option(ctx.sudo().as_ref(), String::from("sudo is not installed"))?;
|
let sudo = require_option(ctx.sudo().as_ref(), String::from("sudo is not installed"))?;
|
||||||
|
let cleanup = ctx.config().cleanup();
|
||||||
let run_type = ctx.run_type();
|
let run_type = ctx.run_type();
|
||||||
print_separator("Flatpak User Packages");
|
print_separator("Flatpak User Packages");
|
||||||
|
|
||||||
@@ -457,20 +458,41 @@ pub fn flatpak_update(ctx: &ExecutionContext) -> Result<()> {
|
|||||||
.execute(&flatpak)
|
.execute(&flatpak)
|
||||||
.args(&["update", "--user", "-y"])
|
.args(&["update", "--user", "-y"])
|
||||||
.check_run()?;
|
.check_run()?;
|
||||||
|
if cleanup {
|
||||||
|
run_type
|
||||||
|
.execute(&flatpak)
|
||||||
|
.args(&["uninstall", "--user", "--unused"])
|
||||||
|
.check_run()?;
|
||||||
|
}
|
||||||
|
|
||||||
print_separator("Flatpak System Packages");
|
print_separator("Flatpak System Packages");
|
||||||
if ctx.config().flatpak_use_sudo() || std::env::var("SSH_CLIENT").is_ok() {
|
if ctx.config().flatpak_use_sudo() || std::env::var("SSH_CLIENT").is_ok() {
|
||||||
run_type
|
run_type
|
||||||
.execute(sudo)
|
.execute(&sudo)
|
||||||
.arg(flatpak)
|
.arg(&flatpak)
|
||||||
.args(&["update", "--system", "-y"])
|
.args(&["update", "--system", "-y"])
|
||||||
.check_run()
|
.check_run()?;
|
||||||
|
if cleanup {
|
||||||
|
run_type
|
||||||
|
.execute(sudo)
|
||||||
|
.arg(flatpak)
|
||||||
|
.args(&["uninstall", "--system", "--unused"])
|
||||||
|
.check_run()?;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
run_type
|
run_type
|
||||||
.execute(&flatpak)
|
.execute(&flatpak)
|
||||||
.args(&["update", "--system", "-y"])
|
.args(&["update", "--system", "-y"])
|
||||||
.check_run()
|
.check_run()?;
|
||||||
|
if cleanup {
|
||||||
|
run_type
|
||||||
|
.execute(flatpak)
|
||||||
|
.args(&["uninstall", "--system", "--unused"])
|
||||||
|
.check_run()?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_snap(sudo: Option<&PathBuf>, run_type: RunType) -> Result<()> {
|
pub fn run_snap(sudo: Option<&PathBuf>, run_type: RunType) -> Result<()> {
|
||||||
|
|||||||
Reference in New Issue
Block a user