Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Add find_incomplete_single to RecoveryManager

Richie McIlroy86e855b1ad3b
diff --git a/Cargo.toml b/Cargo.toml
index 777ba79a1..0fa06ba1d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -64,6 +64,7 @@ cidre = { git = "https://github.com/CapSoftware/cidre", rev = "bf84b67079a8", fe
"dispatch",
"io_surface",
"mtl",
+ "vt",
], default-features = false }
windows = "0.60.0"
diff --git a/apps/desktop/src-tauri/src/recording.rs b/apps/desktop/src-tauri/src/recording.rs
index 12af2a94d..cb24c1afd 100644
--- a/apps/desktop/src-tauri/src/recording.rs
+++ b/apps/desktop/src-tauri/src/recording.rs
@@ -2154,16 +2154,7 @@ pub fn needs_fragment_remux(recording_dir: &Path, meta: &StudioRecordingMeta) ->
}
pub fn remux_fragmented_recording(recording_dir: &Path) -> Result<(), String> {
- let meta = RecordingMeta::load_for_project(recording_dir)
- .map_err(|e| format!("Failed to load recording meta: {e}"))?;
-
- let incomplete =
- RecoveryManager::find_incomplete(recording_dir.parent().unwrap_or(recording_dir));
-
- let incomplete_recording = incomplete
- .into_iter()
- .find(|r| r.project_path == recording_dir)
- .or_else(|| analyze_recording_for_remux(recording_dir, &meta));
+ let incomplete_recording = RecoveryManager::find_incomplete_single(recording_dir);
if let Some(recording) = incomplete_recording {
RecoveryManager::recover(&recording)
diff --git a/crates/recording/src/recovery.rs b/crates/recording/src/recovery.rs
index 52aad3896..aad57fe97 100644
--- a/crates/recording/src/recovery.rs
+++ b/crates/recording/src/recovery.rs
@@ -69,6 +69,26 @@ pub enum RecoveryError {
pub struct RecoveryManager;
impl RecoveryManager {
+ pub fn find_incomplete_single(project_path: &Path) -> Option<IncompleteRecording> {
+ if !project_path.is_dir() {
+ return None;
+ }
+
+ if !project_path.join("recording-meta.json").exists() {
+ return None;
+ }
+
+ let meta = RecordingMeta::load_for_project(project_path).ok()?;
+
+ if let Some(studio_meta) = meta.studio_meta()
+ && Self::should_check_for_recovery(&studio_meta.status())
+ {
+ Self::analyze_incomplete(project_path, &meta)
+ } else {
+ None
+ }
+ }
+
pub fn find_incomplete(recordings_dir: &Path) -> Vec<IncompleteRecording> {
let mut incomplete = Vec::new();
@@ -298,25 +318,8 @@ impl RecoveryManager {
}
if Self::is_video_file(&path) {
- if let Some(init_path) = &init_segment {
- match probe_m4s_can_decode_with_init(init_path, &path) {
- Ok(true) => Some(path),
- Ok(false) => {
- warn!(
- "M4S segment {} has no decodable frames (with init)",
- path.display()
- );
- None
- }
- Err(e) => {
- warn!(
- "M4S segment {} validation failed: {}",
- path.display(),
- e
- );
- None
- }
- }
+ if init_segment.is_some() {
+ Some(path)
} else {
match probe_video_can_decode(&path) {
Ok(true) => Some(path),