backport: fix clippy warnings
This commit is contained in:
parent
0808fb29ab
commit
05ab9aac71
@ -296,38 +296,12 @@ pub async fn media_info(
|
|||||||
post_request(conn, id, json_obj).await
|
post_request(conn, id, json_obj).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn control_service(
|
async fn execute_systemd(
|
||||||
conn: &Pool<Sqlite>,
|
conn: &Pool<Sqlite>,
|
||||||
id: i32,
|
id: i32,
|
||||||
command: &ServiceCmd,
|
command: &ServiceCmd,
|
||||||
engine: Option<web::Data<ProcessControl>>,
|
|
||||||
) -> Result<String, ServiceError> {
|
) -> Result<String, ServiceError> {
|
||||||
if engine.is_some() && engine.as_ref().unwrap().piggyback.load(Ordering::SeqCst) {
|
|
||||||
match command {
|
|
||||||
ServiceCmd::Start => engine.unwrap().start().await,
|
|
||||||
ServiceCmd::Stop => {
|
|
||||||
if control_state(conn, id, "stop_all").await.is_ok() {
|
|
||||||
engine.unwrap().stop().await
|
|
||||||
} else {
|
|
||||||
Err(ServiceError::NoContent("Nothing to stop".to_string()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ServiceCmd::Restart => {
|
|
||||||
if control_state(conn, id, "stop_all").await.is_ok() {
|
|
||||||
engine.unwrap().restart().await
|
|
||||||
} else {
|
|
||||||
Err(ServiceError::NoContent("Nothing to stop".to_string()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ServiceCmd::Status => engine.unwrap().status(),
|
|
||||||
_ => Err(ServiceError::Conflict(
|
|
||||||
"Engine runs in piggyback mode, in this mode this command is not allowed."
|
|
||||||
.to_string(),
|
|
||||||
)),
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
let system_d = SystemD::new(conn, id).await?;
|
let system_d = SystemD::new(conn, id).await?;
|
||||||
|
|
||||||
match command {
|
match command {
|
||||||
ServiceCmd::Enable => system_d.enable(),
|
ServiceCmd::Enable => system_d.enable(),
|
||||||
ServiceCmd::Disable => system_d.disable(),
|
ServiceCmd::Disable => system_d.disable(),
|
||||||
@ -336,5 +310,42 @@ pub async fn control_service(
|
|||||||
ServiceCmd::Restart => system_d.restart(),
|
ServiceCmd::Restart => system_d.restart(),
|
||||||
ServiceCmd::Status => system_d.status().await,
|
ServiceCmd::Status => system_d.status().await,
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn control_service(
|
||||||
|
conn: &Pool<Sqlite>,
|
||||||
|
id: i32,
|
||||||
|
command: &ServiceCmd,
|
||||||
|
engine: Option<web::Data<ProcessControl>>,
|
||||||
|
) -> Result<String, ServiceError> {
|
||||||
|
if let Some(en) = engine {
|
||||||
|
if en.piggyback.load(Ordering::SeqCst) {
|
||||||
|
match command {
|
||||||
|
ServiceCmd::Start => en.start().await,
|
||||||
|
ServiceCmd::Stop => {
|
||||||
|
if control_state(conn, id, "stop_all").await.is_ok() {
|
||||||
|
en.stop().await
|
||||||
|
} else {
|
||||||
|
Err(ServiceError::NoContent("Nothing to stop".to_string()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ServiceCmd::Restart => {
|
||||||
|
if control_state(conn, id, "stop_all").await.is_ok() {
|
||||||
|
en.restart().await
|
||||||
|
} else {
|
||||||
|
Err(ServiceError::NoContent("Nothing to restart".to_string()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ServiceCmd::Status => en.status(),
|
||||||
|
_ => Err(ServiceError::Conflict(
|
||||||
|
"Engine runs in piggyback mode, in this mode this command is not allowed."
|
||||||
|
.to_string(),
|
||||||
|
)),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
execute_systemd(conn, id, command).await
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
execute_systemd(conn, id, command).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user