Skip to content

Commit 9d14a0d

Browse files
make progress_upload required for instant mode
1 parent 8a1d081 commit 9d14a0d

File tree

1 file changed

+76
-79
lines changed

1 file changed

+76
-79
lines changed

apps/desktop/src-tauri/src/recording.rs

Lines changed: 76 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub enum InProgressRecording {
3939
Instant {
4040
target_name: String,
4141
handle: instant_recording::ActorHandle,
42-
progressive_upload: Option<InstantMultipartUpload>,
42+
progressive_upload: InstantMultipartUpload,
4343
video_upload_info: VideoUploadInfo,
4444
inputs: StartRecordingInputs,
4545
recording_dir: PathBuf,
@@ -132,7 +132,7 @@ pub enum CompletedRecording {
132132
Instant {
133133
recording: instant_recording::CompletedRecording,
134134
target_name: String,
135-
progressive_upload: Option<InstantMultipartUpload>,
135+
progressive_upload: InstantMultipartUpload,
136136
video_upload_info: VideoUploadInfo,
137137
},
138138
Studio {
@@ -339,22 +339,11 @@ pub async fn start_recording(
339339
}
340340

341341
let (finish_upload_tx, finish_upload_rx) = flume::bounded(1);
342-
let progressive_upload = video_upload_info
343-
.as_ref()
344-
.filter(|_| matches!(inputs.mode, RecordingMode::Instant))
345-
.map(|video_upload_info| {
346-
InstantMultipartUpload::spawn(
347-
app.clone(),
348-
id.clone(),
349-
recording_dir.join("content/output.mp4"),
350-
video_upload_info.clone(),
351-
Some(finish_upload_rx),
352-
)
353-
});
354342

355343
debug!("spawning start_recording actor");
356344

357345
// done in spawn to catch panics just in case
346+
let app_handle = app.clone();
358347
let spawn_actor_res = async {
359348
spawn_actor({
360349
let state_mtx = Arc::clone(&state_mtx);
@@ -417,6 +406,14 @@ pub async fn start_recording(
417406
return Err("Video upload info not found".to_string());
418407
};
419408

409+
let progressive_upload = InstantMultipartUpload::spawn(
410+
app_handle,
411+
id.clone(),
412+
recording_dir.join("content/output.mp4"),
413+
video_upload_info.clone(),
414+
Some(finish_upload_rx),
415+
);
416+
420417
let mut builder = instant_recording::Actor::builder(
421418
recording_dir.clone(),
422419
inputs.capture_target.clone(),
@@ -757,77 +754,77 @@ async fn handle_recording_finish(
757754
let video_upload_info = video_upload_info.clone();
758755

759756
async move {
760-
if let Some(progressive_upload) = progressive_upload {
761-
let video_upload_succeeded = match progressive_upload
762-
.handle
763-
.await
764-
.map_err(|e| e.to_string())
765-
.and_then(|r| r)
757+
// if let Some(progressive_upload) = progressive_upload {
758+
let video_upload_succeeded = match progressive_upload
759+
.handle
760+
.await
761+
.map_err(|e| e.to_string())
762+
.and_then(|r| r)
763+
{
764+
Ok(()) => {
765+
info!(
766+
"Not attempting instant recording upload as progressive upload succeeded"
767+
);
768+
true
769+
}
770+
Err(e) => {
771+
error!("Progressive upload failed: {}", e);
772+
false
773+
}
774+
};
775+
776+
let _ = screenshot_task.await;
777+
778+
if video_upload_succeeded {
779+
// let resp = prepare_screenshot_upload(
780+
// &app,
781+
// &video_upload_info.config.clone(),
782+
// display_screenshot,
783+
// )
784+
// .await;
785+
786+
// match resp {
787+
// Ok(r)
788+
// if r.status().as_u16() >= 200 && r.status().as_u16() < 300 =>
789+
// {
790+
// info!("Screenshot uploaded successfully");
791+
// }
792+
// Ok(r) => {
793+
// error!("Failed to upload screenshot: {}", r.status());
794+
// }
795+
// Err(e) => {
796+
// error!("Failed to upload screenshot: {e}");
797+
// }
798+
// }
799+
todo!();
800+
} else {
801+
if let Ok(meta) = build_video_meta(&output_path)
802+
.map_err(|err| error!("Error getting video metdata: {}", err))
766803
{
767-
Ok(()) => {
768-
info!(
769-
"Not attempting instant recording upload as progressive upload succeeded"
770-
);
771-
true
772-
}
773-
Err(e) => {
774-
error!("Progressive upload failed: {}", e);
775-
false
776-
}
777-
};
778-
779-
let _ = screenshot_task.await;
780-
781-
if video_upload_succeeded {
782-
// let resp = prepare_screenshot_upload(
783-
// &app,
784-
// &video_upload_info.config.clone(),
785-
// display_screenshot,
786-
// )
787-
// .await;
788-
789-
// match resp {
790-
// Ok(r)
791-
// if r.status().as_u16() >= 200 && r.status().as_u16() < 300 =>
792-
// {
793-
// info!("Screenshot uploaded successfully");
794-
// }
795-
// Ok(r) => {
796-
// error!("Failed to upload screenshot: {}", r.status());
797-
// }
798-
// Err(e) => {
799-
// error!("Failed to upload screenshot: {e}");
800-
// }
801-
// }
802-
todo!();
803-
} else {
804-
if let Ok(meta) = build_video_meta(&output_path)
805-
.map_err(|err| error!("Error getting video metdata: {}", err))
804+
// The upload_video function handles screenshot upload, so we can pass it along
805+
match upload_video(
806+
&app,
807+
video_upload_info.id.clone(),
808+
output_path,
809+
display_screenshot.clone(),
810+
video_upload_info.config.clone(),
811+
meta,
812+
None,
813+
)
814+
.await
806815
{
807-
// The upload_video function handles screenshot upload, so we can pass it along
808-
match upload_video(
809-
&app,
810-
video_upload_info.id.clone(),
811-
output_path,
812-
display_screenshot.clone(),
813-
video_upload_info.config.clone(),
814-
meta,
815-
None,
816-
)
817-
.await
818-
{
819-
Ok(_) => {
820-
info!(
821-
"Final video upload with screenshot completed successfully"
822-
)
823-
}
824-
Err(e) => {
825-
error!("Error in final upload with screenshot: {}", e)
826-
}
816+
Ok(_) => {
817+
info!(
818+
"Final video upload with screenshot completed successfully"
819+
)
820+
}
821+
Err(e) => {
822+
error!("Error in final upload with screenshot: {}", e)
827823
}
828824
}
829825
}
830826
}
827+
// }
831828
}
832829
});
833830

0 commit comments

Comments
 (0)