Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Separate Flatpak user from Flatpak global (fix #67)
Browse files Browse the repository at this point in the history
  • Loading branch information
r-darwish committed Oct 2, 2018
1 parent 4cc0762 commit a9c534a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
34 changes: 30 additions & 4 deletions src/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit a9c534a

Please sign in to comment.