@@ -629,7 +629,8 @@ impl RoomSendQueue {
629
629
} ;
630
630
631
631
let result =
632
- Self :: handle_request ( & room, queued_request, cancel_upload_rx, progress) . await ;
632
+ Self :: handle_request ( & room, queued_request, cancel_upload_rx, progress. clone ( ) )
633
+ . await ;
633
634
634
635
match result {
635
636
Ok ( Some ( parent_key) ) => match queue. mark_as_sent ( & txn_id, parent_key. clone ( ) ) . await
@@ -648,10 +649,7 @@ impl RoomSendQueue {
648
649
file : Some ( media_info. file ) ,
649
650
index,
650
651
is_thumbnail,
651
- progress : TransmissionProgress {
652
- current : media_info. bytes ,
653
- total : media_info. bytes ,
654
- } ,
652
+ progress : progress. map ( |p| p. get ( ) ) . unwrap_or_default ( ) ,
655
653
} ) ;
656
654
}
657
655
} ,
@@ -738,7 +736,7 @@ impl RoomSendQueue {
738
736
room : & Room ,
739
737
request : QueuedRequest ,
740
738
cancel_upload_rx : Option < oneshot:: Receiver < ( ) > > ,
741
- progress_watcher : Option < SharedObservable < TransmissionProgress > > ,
739
+ progress : Option < SharedObservable < TransmissionProgress > > ,
742
740
) -> Result < Option < SentRequestKey > , crate :: Error > {
743
741
match request. kind {
744
742
QueuedRequestKind :: Event { content } => {
@@ -783,8 +781,6 @@ impl RoomSendQueue {
783
781
) )
784
782
} ) ?;
785
783
786
- let bytes;
787
-
788
784
#[ cfg( feature = "e2e-encryption" ) ]
789
785
let media_source = if room. latest_encryption_state ( ) . await ?. is_encrypted ( ) {
790
786
trace ! ( "upload will be encrypted (encrypted room)" ) ;
@@ -794,14 +790,11 @@ impl RoomSendQueue {
794
790
. upload_encrypted_file ( & mut cursor)
795
791
. with_request_config ( RequestConfig :: short_retry ( ) ) ;
796
792
797
- if let Some ( watcher ) = progress_watcher {
798
- req = req. with_send_progress_observable ( watcher ) ;
793
+ if let Some ( progress ) = progress {
794
+ req = req. with_send_progress_observable ( progress ) ;
799
795
} ;
800
796
801
- let progress = req. send_progress . clone ( ) ;
802
797
let encrypted_file = req. await ?;
803
- bytes = progress. get ( ) . total ;
804
-
805
798
MediaSource :: Encrypted ( Box :: new ( encrypted_file) )
806
799
} else {
807
800
trace ! ( "upload will be in clear text (room without encryption)" ) ;
@@ -810,14 +803,11 @@ impl RoomSendQueue {
810
803
let mut req =
811
804
room. client ( ) . media ( ) . upload ( & mime, data, Some ( request_config) ) ;
812
805
813
- if let Some ( watcher ) = progress_watcher {
814
- req = req. with_send_progress_observable ( watcher ) ;
806
+ if let Some ( progress ) = progress {
807
+ req = req. with_send_progress_observable ( progress ) ;
815
808
} ;
816
809
817
- let progress = req. send_progress . clone ( ) ;
818
810
let res = req. await ?;
819
- bytes = progress. get ( ) . total ;
820
-
821
811
MediaSource :: Plain ( res. content_uri )
822
812
} ;
823
813
@@ -828,14 +818,11 @@ impl RoomSendQueue {
828
818
let mut req =
829
819
room. client ( ) . media ( ) . upload ( & mime, data, Some ( request_config) ) ;
830
820
831
- if let Some ( watcher ) = progress_watcher {
832
- req = req. with_send_progress_observable ( watcher ) ;
821
+ if let Some ( progress ) = progress {
822
+ req = req. with_send_progress_observable ( progress ) ;
833
823
} ;
834
824
835
- let progress = req. send_progress . clone ( ) ;
836
825
let res = req. await ?;
837
- bytes = progress. get ( ) . total ;
838
-
839
826
MediaSource :: Plain ( res. content_uri )
840
827
} ;
841
828
@@ -850,7 +837,6 @@ impl RoomSendQueue {
850
837
thumbnail : thumbnail_source,
851
838
#[ cfg( feature = "unstable-msc4274" ) ]
852
839
accumulated,
853
- bytes,
854
840
} ) )
855
841
} ;
856
842
0 commit comments