Skip to content

Commit b953e25

Browse files
committed
fmt
1 parent 7dc68e0 commit b953e25

File tree

2 files changed

+60
-69
lines changed

2 files changed

+60
-69
lines changed

crates/recording/src/cursor.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,11 @@ pub fn spawn_cursor_recorder(
191191

192192
last_mouse_state = mouse_state;
193193

194-
if let Some(ref path) = output_path {
195-
if last_flush.elapsed() >= flush_interval {
196-
flush_cursor_data(path, &response.moves, &response.clicks);
197-
last_flush = Instant::now();
198-
}
194+
if let Some(ref path) = output_path
195+
&& last_flush.elapsed() >= flush_interval
196+
{
197+
flush_cursor_data(path, &response.moves, &response.clicks);
198+
last_flush = Instant::now();
199199
}
200200
}
201201

crates/recording/src/recovery.rs

Lines changed: 55 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,16 @@ impl RecoveryManager {
8181
continue;
8282
};
8383

84-
if let Some(studio_meta) = meta.studio_meta() {
85-
let status = studio_meta.status();
86-
if matches!(
87-
status,
84+
if let Some(studio_meta) = meta.studio_meta()
85+
&& matches!(
86+
studio_meta.status(),
8887
StudioRecordingStatus::InProgress
8988
| StudioRecordingStatus::NeedsRemux
9089
| StudioRecordingStatus::Failed { .. }
91-
) {
92-
if let Some(incomplete_recording) = Self::analyze_incomplete(&path, &meta) {
93-
incomplete.push(incomplete_recording);
94-
}
95-
}
90+
)
91+
&& let Some(incomplete_recording) = Self::analyze_incomplete(&path, &meta)
92+
{
93+
incomplete.push(incomplete_recording);
9694
}
9795
}
9896

@@ -128,12 +126,11 @@ impl RecoveryManager {
128126
let display_dir = segment_path.join("display");
129127
let mut display_fragments = Self::find_complete_fragments(&display_dir);
130128

131-
if display_fragments.is_empty() {
132-
if let Some(display_mp4) =
129+
if display_fragments.is_empty()
130+
&& let Some(display_mp4) =
133131
Self::probe_single_file(&segment_path.join("display.mp4"))
134-
{
135-
display_fragments = vec![display_mp4];
136-
}
132+
{
133+
display_fragments = vec![display_mp4];
137134
}
138135

139136
if display_fragments.is_empty() {
@@ -197,27 +194,25 @@ impl RecoveryManager {
197194
fn find_complete_fragments(dir: &Path) -> Vec<PathBuf> {
198195
let manifest_path = dir.join("manifest.json");
199196

200-
if manifest_path.exists() {
201-
if let Ok(content) = std::fs::read_to_string(&manifest_path) {
202-
if let Ok(manifest) = serde_json::from_str::<serde_json::Value>(&content) {
203-
if let Some(fragments) = manifest.get("fragments").and_then(|f| f.as_array()) {
204-
let result: Vec<PathBuf> = fragments
205-
.iter()
206-
.filter(|f| {
207-
f.get("is_complete")
208-
.and_then(|c| c.as_bool())
209-
.unwrap_or(false)
210-
})
211-
.filter_map(|f| f.get("path").and_then(|p| p.as_str()))
212-
.map(|p| dir.join(p))
213-
.filter(|p| p.exists())
214-
.collect();
215-
216-
if !result.is_empty() {
217-
return result;
218-
}
219-
}
220-
}
197+
if manifest_path.exists()
198+
&& let Ok(content) = std::fs::read_to_string(&manifest_path)
199+
&& let Ok(manifest) = serde_json::from_str::<serde_json::Value>(&content)
200+
&& let Some(fragments) = manifest.get("fragments").and_then(|f| f.as_array())
201+
{
202+
let result: Vec<PathBuf> = fragments
203+
.iter()
204+
.filter(|f| {
205+
f.get("is_complete")
206+
.and_then(|c| c.as_bool())
207+
.unwrap_or(false)
208+
})
209+
.filter_map(|f| f.get("path").and_then(|p| p.as_str()))
210+
.map(|p| dir.join(p))
211+
.filter(|p| p.exists())
212+
.collect();
213+
214+
if !result.is_empty() {
215+
return result;
221216
}
222217
}
223218

@@ -671,14 +666,11 @@ impl RecoveryManager {
671666
return Cursors::default();
672667
}
673668

674-
if let Ok(meta) = RecordingMeta::load_for_project(project_path) {
675-
if let Some(studio_meta) = meta.studio_meta() {
676-
if let StudioRecordingMeta::MultipleSegments { inner, .. } = studio_meta {
677-
if !inner.cursors.is_empty() {
678-
return inner.cursors.clone();
679-
}
680-
}
681-
}
669+
if let Ok(meta) = RecordingMeta::load_for_project(project_path)
670+
&& let Some(StudioRecordingMeta::MultipleSegments { inner, .. }) = meta.studio_meta()
671+
&& !inner.cursors.is_empty()
672+
{
673+
return inner.cursors.clone();
682674
}
683675

684676
Self::scan_cursor_images(&cursors_dir)
@@ -693,28 +685,27 @@ impl RecoveryManager {
693685

694686
for entry in entries.flatten() {
695687
let path = entry.path();
696-
if path.extension().map(|e| e == "png").unwrap_or(false) {
697-
if let Some(file_name) = path.file_stem().and_then(|s| s.to_str()) {
698-
if let Some(id_str) = file_name.strip_prefix("cursor_") {
699-
let relative_path = RelativePathBuf::from("content/cursors")
700-
.join(path.file_name().unwrap().to_str().unwrap());
701-
702-
cursors.insert(
703-
id_str.to_string(),
704-
cap_project::CursorMeta {
705-
image_path: relative_path,
706-
hotspot: cap_project::XY::new(0.0, 0.0),
707-
shape: None,
708-
},
709-
);
688+
if path.extension().map(|e| e == "png").unwrap_or(false)
689+
&& let Some(file_name) = path.file_stem().and_then(|s| s.to_str())
690+
&& let Some(id_str) = file_name.strip_prefix("cursor_")
691+
{
692+
let relative_path = RelativePathBuf::from("content/cursors")
693+
.join(path.file_name().unwrap().to_str().unwrap());
694+
695+
cursors.insert(
696+
id_str.to_string(),
697+
cap_project::CursorMeta {
698+
image_path: relative_path,
699+
hotspot: cap_project::XY::new(0.0, 0.0),
700+
shape: None,
701+
},
702+
);
710703

711-
info!(
712-
"Recovered cursor {} from image file: {:?}",
713-
id_str,
714-
path.file_name()
715-
);
716-
}
717-
}
704+
info!(
705+
"Recovered cursor {} from image file: {:?}",
706+
id_str,
707+
path.file_name()
708+
);
718709
}
719710
}
720711

0 commit comments

Comments
 (0)