mirror of
https://github.com/samsonjs/vibetunnel.git
synced 2026-04-03 10:55:54 +00:00
Fix CI: Apply cargo fmt to latest changes
This commit is contained in:
parent
779f8f3360
commit
db4b60e5f7
4 changed files with 15 additions and 12 deletions
|
|
@ -1014,7 +1014,7 @@ fn handle_session_kill(control_path: &Path, path: &str) -> Response<String> {
|
|||
// Update session status to exited if not already
|
||||
let session_path = control_path.join(&session_id);
|
||||
let session_json_path = session_path.join("session.json");
|
||||
|
||||
|
||||
if let Ok(content) = std::fs::read_to_string(&session_json_path) {
|
||||
if let Ok(mut session_info) = serde_json::from_str::<serde_json::Value>(&content) {
|
||||
if session_info.get("status").and_then(|s| s.as_str()) != Some("exited") {
|
||||
|
|
@ -1025,7 +1025,7 @@ fn handle_session_kill(control_path: &Path, path: &str) -> Response<String> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let response = ApiResponse {
|
||||
success: Some(true),
|
||||
message: Some("Session killed".to_string()),
|
||||
|
|
@ -1041,7 +1041,7 @@ fn handle_session_kill(control_path: &Path, path: &str) -> Response<String> {
|
|||
// Update session status to exited after killing the process
|
||||
let session_path = control_path.join(&session_id);
|
||||
let session_json_path = session_path.join("session.json");
|
||||
|
||||
|
||||
if let Ok(content) = std::fs::read_to_string(&session_json_path) {
|
||||
if let Ok(mut session_info) = serde_json::from_str::<serde_json::Value>(&content) {
|
||||
session_info["status"] = serde_json::json!("exited");
|
||||
|
|
@ -1051,9 +1051,9 @@ fn handle_session_kill(control_path: &Path, path: &str) -> Response<String> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
(StatusCode::OK, "Session killed")
|
||||
},
|
||||
}
|
||||
Err(e) => {
|
||||
let response = ApiResponse {
|
||||
success: None,
|
||||
|
|
|
|||
|
|
@ -597,17 +597,19 @@ impl Iterator for StreamingIterator {
|
|||
if self.wait_start.is_none() {
|
||||
self.wait_start = Some(SystemTime::now());
|
||||
}
|
||||
|
||||
|
||||
// Check if we've been waiting too long (5 seconds timeout)
|
||||
if let Some(wait_start) = self.wait_start {
|
||||
if wait_start.elapsed().unwrap_or_default() > std::time::Duration::from_secs(5) {
|
||||
if wait_start.elapsed().unwrap_or_default()
|
||||
> std::time::Duration::from_secs(5)
|
||||
{
|
||||
self.state = StreamingState::Error(
|
||||
"Timeout waiting for stream file to be created".to_string()
|
||||
"Timeout waiting for stream file to be created".to_string(),
|
||||
);
|
||||
return None;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// File doesn't exist yet, wait 50ms and return None to retry later
|
||||
std::thread::sleep(std::time::Duration::from_millis(50));
|
||||
return None;
|
||||
|
|
|
|||
|
|
@ -404,12 +404,12 @@ fn handle_pty_session(
|
|||
}
|
||||
0 => {
|
||||
eprintln!("PTY closed (EOF), updating session status");
|
||||
|
||||
|
||||
// Send exit event to stream before updating session status
|
||||
let exit_event = json!(["exit", 0, session_id]);
|
||||
writeln!(writer, "{exit_event}")?;
|
||||
writer.flush()?;
|
||||
|
||||
|
||||
// Update session status to exited
|
||||
let session_json_path = format!("{session_dir}/session.json");
|
||||
if let Ok(content) = std::fs::read_to_string(&session_json_path) {
|
||||
|
|
|
|||
|
|
@ -449,7 +449,8 @@ fn spawn(mut opts: SpawnOptions) -> Result<i32, Error> {
|
|||
|
||||
// Send exit event to stream before updating session status
|
||||
if let Some(ref mut stream_writer) = stream_writer {
|
||||
let session_id = opts.session_json_path
|
||||
let session_id = opts
|
||||
.session_json_path
|
||||
.as_ref()
|
||||
.and_then(|p| p.file_stem())
|
||||
.and_then(|s| s.to_str())
|
||||
|
|
|
|||
Loading…
Reference in a new issue