@@ -45,7 +45,7 @@ use std::time::Duration;
4545
4646pub use api:: GeneralConfiguration ;
4747use async_trait:: async_trait;
48- use asynch:: { AsyncTask , ReqwestClientFactory , SyncStatus } ;
48+ use asynch:: { AsyncTask , SyncStatus } ;
4949use futures:: { future, select, FutureExt } ;
5050use log:: * ;
5151
@@ -143,6 +143,8 @@ struct CoreLogicHandler {
143143 // Keeps the sensitive data
144144 safe : Safe ,
145145 configuration : RklConfiguration ,
146+ dbx_synchronizer : dropbox:: Synchronizer ,
147+ nc_synchronizer : nextcloud:: Synchronizer ,
146148 // Signals changes that are not saved
147149 contents_changed : bool ,
148150 cryptor : datacrypt:: BcryptAes ,
@@ -187,12 +189,30 @@ impl CoreLogicHandler {
187189 user_selection = us;
188190 cr
189191 } ;
192+
193+ // Initialize the synchronizers
194+ let mut nc_synchronizer = nextcloud:: Synchronizer :: new (
195+ & configuration. nextcloud ,
196+ & configuration. system ,
197+ FILENAME
198+ ) . unwrap ( ) ;
199+ nc_synchronizer. init ( ) . await ;
200+
201+ let mut dbx_synchronizer = dropbox:: Synchronizer :: new (
202+ & configuration. dropbox ,
203+ & configuration. system ,
204+ FILENAME
205+ ) . unwrap ( ) ;
206+ dbx_synchronizer. init ( ) . await ;
207+
190208 CoreLogicHandler {
191209 editor,
192210 props : props,
193211 user_selection,
194212 safe,
195213 configuration,
214+ dbx_synchronizer,
215+ nc_synchronizer,
196216 contents_changed,
197217 cryptor,
198218 }
@@ -788,25 +808,11 @@ Warning: Saving will discard all the entries that could not be recovered.
788808 }
789809 } ;
790810
791- // Initialize the synchronizers
792- let mut nc_synchronizer = nextcloud:: Synchronizer :: new (
793- & s. configuration . nextcloud ,
794- & s. configuration . system ,
795- FILENAME
796- ) . unwrap ( ) ;
797- nc_synchronizer. init ( ) . await ;
798-
799- let mut dbx_synchronizer = dropbox:: Synchronizer :: new (
800- & s. configuration . dropbox ,
801- & s. configuration . system ,
802- FILENAME ,
803- Box :: new ( ReqwestClientFactory :: new ( ) )
804- ) . unwrap ( ) ;
805- dbx_synchronizer. init ( ) . await ;
806-
807811 // Prepare all the possible futures from which we expect possible user_selection
808- let mut nc_future = nc_synchronizer. execute ( ) . fuse ( ) ;
809- let mut dbx_future = dbx_synchronizer. execute ( ) . fuse ( ) ;
812+ let nc_synchronizer_clonne = s. nc_synchronizer . clone ( ) ;
813+ let dbx_synchronizer_clone = s. dbx_synchronizer . clone ( ) ;
814+ let mut nc_future = nc_synchronizer_clonne. execute ( ) . fuse ( ) ;
815+ let mut dbx_future = dbx_synchronizer_clone. execute ( ) . fuse ( ) ;
810816 let mut fused_user_selection_future = user_selection_future. fuse ( ) ;
811817 let mut inactivity_timeout_future = Box :: pin ( sleep ( Duration :: from_secs ( s. props . idle_timeout_seconds ( ) as u64 ) ) ) . fuse ( ) ;
812818
0 commit comments