Fix minor bugs and cleanup
parent
dd3552336f
commit
cc76c5b5bd
|
|
@ -9,12 +9,12 @@ use cypraea_common::paths;
|
|||
use cypraea_common::protocol::{ClientMessage, DaemonMessage};
|
||||
use rustyline::error::ReadlineError;
|
||||
use rustyline::DefaultEditor;
|
||||
use serde_json::Deserializer;
|
||||
//use serde_json::Deserializer;
|
||||
use std::io::{self, Write};
|
||||
use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader};
|
||||
use tokio::net::UnixStream;
|
||||
use tokio::sync::mpsc;
|
||||
use tracing::{debug, error, info, warn};
|
||||
use tracing::{debug, error, info /*,warn*/};
|
||||
|
||||
mod display;
|
||||
|
||||
|
|
@ -195,7 +195,7 @@ async fn run_repl(
|
|||
// Wait for the session info response
|
||||
let mut session_info = None;
|
||||
if let Some(msg) = rx.recv().await {
|
||||
if let DaemonMessage::SessionInfo { session: info } = msg {
|
||||
if let DaemonMessage::SessionDetails { session: info } = msg {
|
||||
session_info = Some(info);
|
||||
}
|
||||
}
|
||||
|
|
@ -276,7 +276,7 @@ async fn run_repl(
|
|||
send_message(&mut writer, &info_msg).await
|
||||
.context("Failed to send session info message")?;
|
||||
}
|
||||
Some(DaemonMessage::SessionInfo { session: info }) => {
|
||||
Some(DaemonMessage::SessionDetails { session: info }) => {
|
||||
session_info = Some(info);
|
||||
}
|
||||
Some(DaemonMessage::Error { message }) => {
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@
|
|||
//!
|
||||
//! This module handles logging command execution and other events to a SQLite database.
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use anyhow::{anyhow, Context, Result};
|
||||
use chrono::{DateTime, Utc};
|
||||
use rusqlite::{params, Connection};
|
||||
use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::Mutex;
|
||||
use tracing::{debug, error, info};
|
||||
use tracing::{debug, /*error,*/ info};
|
||||
|
||||
/// Database connection wrapper.
|
||||
#[derive(Clone)]
|
||||
|
|
@ -109,7 +109,9 @@ impl Database {
|
|||
],
|
||||
)
|
||||
.context("Failed to insert command record")?;
|
||||
|
||||
if res != 1 {
|
||||
return Err(anyhow!("Failed to insert command record"));
|
||||
}
|
||||
Ok(conn.last_insert_rowid())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
use anyhow::{Context, Result};
|
||||
use clap::Parser;
|
||||
use tracing::{info, warn, error};
|
||||
use tracing::{info /*, warn, error*/};
|
||||
use cypraea_common::paths;
|
||||
|
||||
mod db;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
use anyhow::{Context, Result};
|
||||
use std::process::Stdio;
|
||||
use tokio::io::{AsyncBufReadExt, AsyncRead, BufReader};
|
||||
use tokio::process::{Child, Command};
|
||||
use tokio::process::{/*Child,*/ Command};
|
||||
use tokio::sync::mpsc;
|
||||
|
||||
/// Output capture result.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
//! and command execution within sessions.
|
||||
|
||||
use anyhow::{anyhow, Context, Result};
|
||||
use chrono::{DateTime, Duration, Utc};
|
||||
use chrono::{DateTime, /*Duration,*/ Utc};
|
||||
use cypraea_common::protocol::SessionInfo;
|
||||
use shell_words;
|
||||
use std::collections::HashMap;
|
||||
|
|
@ -12,9 +12,9 @@ use std::path::{Path, PathBuf};
|
|||
use std::process::Stdio;
|
||||
use std::sync::Arc;
|
||||
use tokio::io::{AsyncBufReadExt, AsyncRead, BufReader};
|
||||
use tokio::process::{Child, Command};
|
||||
use tokio::process::{/*Child,*/ Command};
|
||||
use tokio::sync::{mpsc, Mutex, RwLock};
|
||||
use tracing::{debug, error, info, warn};
|
||||
use tracing::{/*debug,*/ error, info /*, warn*/};
|
||||
|
||||
use crate::db::{CommandRecord, Database};
|
||||
|
||||
|
|
@ -198,8 +198,8 @@ impl Session {
|
|||
tokio::spawn(stderr_future);
|
||||
|
||||
// Collect stdout and stderr for logging
|
||||
let mut stdout_buffer = Vec::new();
|
||||
let mut stderr_buffer = Vec::new();
|
||||
let stdout_buffer = Vec::new();
|
||||
let stderr_buffer = Vec::new();
|
||||
|
||||
// Wait for the command to finish
|
||||
let status = child.wait().await.context("Failed to wait for command")?;
|
||||
|
|
|
|||
|
|
@ -4,13 +4,13 @@
|
|||
|
||||
use anyhow::{Context, Result};
|
||||
use cypraea_common::protocol::{ClientMessage, DaemonMessage};
|
||||
use serde_json::Deserializer;
|
||||
//use serde_json::Deserializer;
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader, BufWriter};
|
||||
use tokio::net::{UnixListener, UnixStream};
|
||||
use tokio::sync::mpsc;
|
||||
use tracing::{debug, error, info, warn};
|
||||
use tracing::{debug, error, info /*, warn*/};
|
||||
|
||||
use crate::session::SessionManager;
|
||||
|
||||
|
|
@ -217,7 +217,7 @@ async fn process_message(
|
|||
|
||||
// Send session info
|
||||
let info = session_guard.get_info();
|
||||
let msg = DaemonMessage::SessionInfo { session: info };
|
||||
let msg = DaemonMessage::SessionDetails { session: info };
|
||||
tx.send(msg).await.context("Failed to send session info")?;
|
||||
}
|
||||
|
||||
|
|
@ -249,7 +249,7 @@ async fn process_message(
|
|||
|
||||
// Send session info
|
||||
let info = session_guard.get_info();
|
||||
let msg = DaemonMessage::SessionInfo { session: info };
|
||||
let msg = DaemonMessage::SessionDetails { session: info };
|
||||
tx.send(msg).await.context("Failed to send session info")?;
|
||||
}
|
||||
|
||||
|
|
@ -290,7 +290,7 @@ async fn process_message(
|
|||
|
||||
let session_guard = session_arc.lock().await;
|
||||
let info = session_guard.get_info();
|
||||
let msg = DaemonMessage::SessionInfo { session: info };
|
||||
let msg = DaemonMessage::SessionDetails { session: info };
|
||||
tx.send(msg).await.context("Failed to send session info")?;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue