@@ -1050,13 +1050,14 @@ impl PutWindow {
10501050}
10511051}
10521052 mutant_protocol:: PutEvent :: Complete =>{
1053- log:: info!( "Put operationphase completed successfully" ) ;
1053+ log:: info!( "Put operation completed successfully" ) ;
10541054
1055- //Check which phasejust completed
1055+ //For phasetracking, detect if this is the first completion (Phase 1)
10561056let current_phase_val =* current_phase. read ( ) . unwrap ( ) ;
1057+ let is_public = public;
10571058
1058- if current_phase_val ==1 {
1059- // Phase 1(file data) is complete
1059+ if is_public && current_phase_val ==1 {
1060+ //This is the end of Phase 1for a public upload
10601061* phase1_complete. write ( ) . unwrap ( ) =true ;
10611062
10621063// Store Phase 1 progress
@@ -1065,34 +1066,19 @@ impl PutWindow {
10651066* phase1_confirmation_progress. write ( ) . unwrap ( ) =* confirmation_progress. read ( ) . unwrap ( ) ;
10661067* phase1_total_chunks. write ( ) . unwrap ( ) =* total_chunks. read ( ) . unwrap ( ) ;
10671068
1068- if public{
1069- // For public uploads, move to Phase 2 (public index upload)
1070- * current_phase. write ( ) . unwrap ( ) =2 ;
1071-
1072- // Reset current progress for Phase 2
1073- * reservation_progress. write ( ) . unwrap ( ) =0.0 ;
1074- * upload_progress. write ( ) . unwrap ( ) =0.0 ;
1075- * confirmation_progress. write ( ) . unwrap ( ) =0.0 ;
1076- * total_chunks. write ( ) . unwrap ( ) =0 ;
1077-
1078- // Don't mark as complete yet - wait for Phase 2
1079- log:: info!( "Phase 1 complete, waiting for Phase 2 (public index upload)" ) ;
1080- // Continue listening for Phase 2 events
1081- } else {
1082- // For private uploads, we're done after Phase 1
1083- * upload_complete_clone. write ( ) . unwrap ( ) =true ;
1084- * is_uploading_clone. write ( ) . unwrap ( ) =false ;
1085-
1086- // Refresh the keys list
1087- spawn_local ( async move {
1088- let ctx = context:: context ( ) ;
1089- let _ = ctx. list_keys ( ) . await ;
1090- } ) ;
1091-
1092- break ;
1093- }
1094- } else if current_phase_val ==2 {
1095- // Phase 2 (public index) is complete
1069+ // Move to Phase 2 for UI display
1070+ * current_phase. write ( ) . unwrap ( ) =2 ;
1071+
1072+ // Reset current progress for Phase 2 display
1073+ * reservation_progress. write ( ) . unwrap ( ) =0.0 ;
1074+ * upload_progress. write ( ) . unwrap ( ) =0.0 ;
1075+ * confirmation_progress. write ( ) . unwrap ( ) =0.0 ;
1076+ * total_chunks. write ( ) . unwrap ( ) =0 ;
1077+
1078+ log:: info!( "Phase 1 complete, transitioning to Phase 2 display" ) ;
1079+ // Continue listening for Phase 2 events - don't break yet
1080+ } else if is_public && current_phase_val ==2 {
1081+ // This is the end of Phase 2 for a public upload
10961082* phase2_complete. write ( ) . unwrap ( ) =true ;
10971083
10981084// Store Phase 2 progress
@@ -1101,7 +1087,12 @@ impl PutWindow {
11011087* phase2_confirmation_progress. write ( ) . unwrap ( ) =* confirmation_progress. read ( ) . unwrap ( ) ;
11021088* phase2_total_chunks. write ( ) . unwrap ( ) =* total_chunks. read ( ) . unwrap ( ) ;
11031089
1104- // Both phases complete for public upload
1090+ log:: info!( "Phase 2 complete, continuing to listen for final completion" ) ;
1091+ // Continue listening - the daemon will send final completion after auto-indexing
1092+ } else {
1093+ // This is either:
1094+ // 1. A private upload completion (single phase)
1095+ // 2. The final completion for a public upload (after auto-indexing)
11051096* upload_complete_clone. write ( ) . unwrap ( ) =true ;
11061097* is_uploading_clone. write ( ) . unwrap ( ) =false ;
11071098
@@ -1110,19 +1101,21 @@ impl PutWindow {
11101101let ctx = context:: context ( ) ;
11111102let _ = ctx. list_keys ( ) . await ;
11121103
1113- // Fetch the key details to get the public address
1114- let keys = ctx. list_keys ( ) . await ;
1115- for keyin keys{
1116- if key. key == key_name_clone && key. is_public {
1117- if let Some ( addr) = key. public_address {
1118- * public_address. write ( ) . unwrap ( ) =Some ( addr) ;
1119- break ;
1104+ // For public uploads, fetch the public address
1105+ if is_public{
1106+ let keys = ctx. list_keys ( ) . await ;
1107+ for keyin keys{
1108+ if key. key == key_name_clone && key. is_public {
1109+ if let Some ( addr) = key. public_address {
1110+ * public_address. write ( ) . unwrap ( ) =Some ( addr) ;
1111+ break ;
1112+ }
11201113}
11211114}
11221115}
11231116} ) ;
11241117
1125- log:: info!( "Phase 2 complete, public upload finished " ) ;
1118+ log:: info!( "Upload completed successfully " ) ;
11261119break ;
11271120}
11281121}