@@ -30,8 +30,8 @@ use auth::{AuthStore, AuthenticationInvalid, Plan};
30
30
use camera:: CameraPreviewState ;
31
31
use cap_editor:: { EditorInstance , EditorState } ;
32
32
use cap_project:: {
33
- ProjectConfiguration , RecordingMeta , RecordingMetaInner , SharingMeta , StudioRecordingMeta , XY ,
34
- ZoomSegment ,
33
+ ProjectConfiguration , RecordingMeta , RecordingMetaInner , SharingMeta , StudioRecordingMeta ,
34
+ StudioRecordingStatus , XY , ZoomSegment ,
35
35
} ;
36
36
use cap_recording:: {
37
37
RecordingMode ,
@@ -901,21 +901,24 @@ async fn get_video_metadata(path: PathBuf) -> Result<VideoRecordingMetadata, Str
901
901
RecordingMetaInner :: Instant ( _) => {
902
902
vec ! [ path. join( "content/output.mp4" ) ]
903
903
}
904
- RecordingMetaInner :: Studio ( meta) => match meta {
905
- StudioRecordingMeta :: SingleSegment { segment } => {
906
- vec ! [ recording_meta. path( & segment. display. path) ]
904
+ RecordingMetaInner :: Studio ( meta) => {
905
+ let status = meta. status ( ) ;
906
+ if let StudioRecordingStatus :: Failed { .. } = status {
907
+ return Err ( format ! ( "Unable to get metadata on failed recording" ) ) ;
908
+ } else if let StudioRecordingStatus :: InProgress = status {
909
+ return Err ( format ! ( "Unable to get metadata on in-progress recording" ) ) ;
910
+ }
911
+
912
+ match meta {
913
+ StudioRecordingMeta :: SingleSegment { segment } => {
914
+ vec ! [ recording_meta. path( & segment. display. path) ]
915
+ }
916
+ StudioRecordingMeta :: MultipleSegments { inner } => inner
917
+ . segments
918
+ . iter ( )
919
+ . map ( |s| recording_meta. path ( & s. display . path ) )
920
+ . collect ( ) ,
907
921
}
908
- StudioRecordingMeta :: MultipleSegments { inner, .. } => inner
909
- . segments
910
- . iter ( )
911
- . map ( |s| recording_meta. path ( & s. display . path ) )
912
- . collect ( ) ,
913
- } ,
914
- RecordingMetaInner :: InProgress { .. } => {
915
- return Err ( format ! ( "Unable to get metadata on in-progress recording" ) ) ;
916
- }
917
- RecordingMetaInner :: Failed { .. } => {
918
- return Err ( format ! ( "Unable to get metadata on failed recording" ) ) ;
919
922
}
920
923
} ;
921
924
@@ -1069,11 +1072,7 @@ async fn upload_exported_video(
1069
1072
1070
1073
let mut meta = RecordingMeta :: load_for_project ( & path) . map_err ( |v| v. to_string ( ) ) ?;
1071
1074
1072
- let Some ( output_path) = meta. output_path ( ) else {
1073
- notifications:: send_notification ( & app, notifications:: NotificationType :: UploadFailed ) ;
1074
- return Err ( "Failed to upload video: Recording failed to complete" . to_string ( ) ) ;
1075
- } ;
1076
-
1075
+ let output_path = meta. output_path ( ) ;
1077
1076
if !output_path. exists ( ) {
1078
1077
notifications:: send_notification ( & app, notifications:: NotificationType :: UploadFailed ) ;
1079
1078
return Err ( "Failed to upload video: Rendered video not found" . to_string ( ) ) ;
@@ -1401,17 +1400,6 @@ async fn save_file_dialog(
1401
1400
}
1402
1401
}
1403
1402
1404
- // #[derive(Serialize, specta::Type)]
1405
- // #[serde(tag = "status")]
1406
- // pub enum RecordingStatus {
1407
- // Recording,
1408
- // Failed { error: String },
1409
- // Complete { mode: RecordingMode },
1410
- // }
1411
- //
1412
- // #[serde(flatten)]
1413
- // pub status: RecordingStatus,
1414
-
1415
1403
#[ derive( Serialize , specta:: Type ) ]
1416
1404
pub struct RecordingMetaWithMode {
1417
1405
#[ serde( flatten) ]
@@ -1425,8 +1413,6 @@ impl RecordingMetaWithMode {
1425
1413
mode : match & inner. inner {
1426
1414
RecordingMetaInner :: Studio ( _) => Some ( RecordingMode :: Studio ) ,
1427
1415
RecordingMetaInner :: Instant ( _) => Some ( RecordingMode :: Instant ) ,
1428
- RecordingMetaInner :: InProgress { .. } => None ,
1429
- RecordingMetaInner :: Failed { .. } => None ,
1430
1416
} ,
1431
1417
inner,
1432
1418
}
@@ -2498,9 +2484,15 @@ fn open_project_from_path(path: &Path, app: AppHandle) -> Result<(), String> {
2498
2484
let meta = RecordingMeta :: load_for_project ( path) . map_err ( |v| v. to_string ( ) ) ?;
2499
2485
2500
2486
match & meta. inner {
2501
- RecordingMetaInner :: Studio ( _) => {
2502
- let project_path = path. to_path_buf ( ) ;
2487
+ RecordingMetaInner :: Studio ( meta) => {
2488
+ let status = meta. status ( ) ;
2489
+ if let StudioRecordingStatus :: Failed { .. } = status {
2490
+ return Err ( format ! ( "Unable to open failed recording" ) ) ;
2491
+ } else if let StudioRecordingStatus :: InProgress = status {
2492
+ return Err ( format ! ( "Recording in progress" ) ) ;
2493
+ }
2503
2494
2495
+ let project_path = path. to_path_buf ( ) ;
2504
2496
tokio:: spawn ( async move { ShowCapWindow :: Editor { project_path } . show ( & app) . await } ) ;
2505
2497
}
2506
2498
RecordingMetaInner :: Instant ( _) => {
@@ -2515,10 +2507,6 @@ fn open_project_from_path(path: &Path, app: AppHandle) -> Result<(), String> {
2515
2507
}
2516
2508
}
2517
2509
}
2518
- RecordingMetaInner :: InProgress { .. } => return Err ( format ! ( "Recording in progress" ) ) ,
2519
- RecordingMetaInner :: Failed { .. } => {
2520
- return Err ( format ! ( "Unable to open failed recording" ) ) ;
2521
- }
2522
2510
}
2523
2511
2524
2512
Ok ( ( ) )
0 commit comments