Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(cli): defer stop SIGTERM until timeout and archive session logs

Richie McIlroy4b5639397af8
diff --git a/apps/cli/src/session.rs b/apps/cli/src/session.rs
index 27473192f..95090063d 100644
--- a/apps/cli/src/session.rs
+++ b/apps/cli/src/session.rs
@@ -118,6 +118,27 @@ pub fn cleanup(id: &str) {
}
}
+pub fn archive_log(id: &str, project_path: &Path) -> Result<Option<PathBuf>, String> {
+ let source = log_file(id)?;
+ if !source.exists() {
+ return Ok(None);
+ }
+ if project_path.as_os_str().is_empty() || !project_path.is_dir() {
+ return Ok(None);
+ }
+
+ let destination = project_path.join("detached-session.log");
+ std::fs::copy(&source, &destination).map_err(|e| {
+ format!(
+ "Could not archive session log {} to {}: {e}",
+ source.display(),
+ destination.display()
+ )
+ })?;
+
+ Ok(Some(destination))
+}
+
/// Whether `pid` is still running. On unix `kill(pid, 0)` probes existence without signalling; on
/// Windows a zero-timeout wait on the process handle does the equivalent.
#[cfg(unix)]