mirror of
https://gitlab.steamos.cloud/holo/steamos-manager.git
synced 2025-07-15 18:56:49 -04:00
job: Add method to mirror jobs from an already-running daemon
This commit is contained in:
parent
0626012748
commit
3c56afe921
3 changed files with 36 additions and 4 deletions
23
src/job.rs
23
src/job.rs
|
@ -12,11 +12,14 @@ use nix::sys::signal::Signal;
|
|||
use nix::unistd::Pid;
|
||||
use std::collections::HashMap;
|
||||
use std::ffi::OsStr;
|
||||
use std::io::Cursor;
|
||||
use std::os::unix::process::ExitStatusExt;
|
||||
use std::process::ExitStatus;
|
||||
use tokio::process::{Child, Command};
|
||||
use tracing::error;
|
||||
use zbus::{fdo, interface, zvariant, Connection, Interface, InterfaceRef, SignalContext};
|
||||
use zbus::fdo::{self, IntrospectableProxy};
|
||||
use zbus::{interface, zvariant, Connection, Interface, InterfaceRef, SignalContext};
|
||||
use zbus_xml::Node;
|
||||
|
||||
use crate::error::{to_zbus_fdo_error, zbus_to_zbus_fdo};
|
||||
use crate::proxy::JobProxy;
|
||||
|
@ -117,6 +120,24 @@ impl JobManager {
|
|||
self.mirrored_jobs.insert(name, object_path.to_owned());
|
||||
Ok(object_path)
|
||||
}
|
||||
|
||||
pub async fn mirror_connection(&mut self, connection: &Connection) -> fdo::Result<()> {
|
||||
let proxy = IntrospectableProxy::builder(connection)
|
||||
.destination("com.steampowered.SteamOSManager1")?
|
||||
.path(JOB_PREFIX)?
|
||||
.build()
|
||||
.await?;
|
||||
let introspection = proxy.introspect().await?;
|
||||
let introspection =
|
||||
Node::from_reader(Cursor::new(introspection)).map_err(to_zbus_fdo_error)?;
|
||||
for node in introspection.nodes() {
|
||||
if let Some(name) = node.name() {
|
||||
self.mirror_job(connection, format!("{JOB_PREFIX}/{name}"))
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[interface(name = "com.steampowered.SteamOSManager1.JobManager")]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue