Separate Flatpak user from Flatpak global (fix #67)

This commit is contained in:
Roey Darwish Dror
2018-10-02 14:30:10 +03:00
parent 4cc076212c
commit a9c534a2a2
2 changed files with 35 additions and 5 deletions

View File

@@ -220,20 +220,46 @@ pub fn run_fwupdmgr(terminal: &mut Terminal, dry_run: bool) -> Option<(&'static
}
#[must_use]
pub fn run_flatpak(terminal: &mut Terminal, dry_run: bool) -> Option<(&'static str, bool)> {
pub fn flatpak_user_update(terminal: &mut Terminal, dry_run: bool) -> Option<(&'static str, bool)> {
if let Some(flatpak) = which("flatpak") {
terminal.print_separator("Flatpak");
terminal.print_separator("Flatpak User Packages");
let success = || -> Result<(), failure::Error> {
Executor::new(&flatpak, dry_run)
.args(&["update", "-y"])
.args(&["update", "--user", "-y"])
.spawn()?
.wait()?
.check()?;
Ok(())
}().is_ok();
return Some(("Flatpak", success));
return Some(("Flatpak User Packages", success));
}
None
}
#[must_use]
pub fn flatpak_global_update(
sudo: &Option<PathBuf>,
terminal: &mut Terminal,
dry_run: bool,
) -> Option<(&'static str, bool)> {
if let Some(sudo) = sudo {
if let Some(flatpak) = which("flatpak") {
terminal.print_separator("Flatpak Global Packages");
let success = || -> Result<(), failure::Error> {
Executor::new(&sudo, dry_run)
.args(&[flatpak.to_str().unwrap(), "update", "-y"])
.spawn()?
.wait()?
.check()?;
Ok(())
}().is_ok();
return Some(("Flatpak Global Packages", success));
}
}
None

View File

@@ -250,7 +250,11 @@ fn run() -> Result<(), Error> {
#[cfg(target_os = "linux")]
{
report.push_result(execute(
|terminal| linux::run_flatpak(terminal, opt.dry_run),
|terminal| linux::flatpak_user_update(terminal, opt.dry_run),
&mut terminal,
));
report.push_result(execute(
|terminal| linux::flatpak_global_update(&sudo, terminal, opt.dry_run),
&mut terminal,
));
report.push_result(execute(