@@ -17,6 +17,7 @@ class AppStartManager:
1717 updater = inject .attr (AutoUpdater )
1818 state_controller = inject .attr (FilterStateController )
1919 interaction_manager = inject .attr (InteractionManager )
20+ config_file_manager = inject .attr (ConfigFileManager )
2021 config = inject .attr (ConfigObj )
2122 inversion_rules_file_manager = inject .attr (RulesFileManager )
2223 main_executor = inject .attr (MainExecutor )
@@ -25,7 +26,8 @@ class AppStartManager:
2526
2627 def setup (self ):
2728 self .close_manager .setup ()
28- self .updater .on_update_applied = self .handle_update
29+ self .config_file_manager .setup ()
30+ self .inversion_rules_file_manager .setup ()
2931 self .interaction_manager .setup ()
3032 self .tray .setup ()
3133
@@ -55,40 +57,12 @@ async def run(self):
5557 pass
5658 print ("Bye" )
5759
58- def handle_update (self ,
59- new_path : Path ,
60- current_path : Path ,
61- backup_filename : str ):
62- try :
63- from shutil import copyfile
64- from os import path
65-
66- copy_list = [
67- self .config .filename ,
68- self .inversion_rules_file_manager .filename
69- ]
70-
71- for filename in copy_list :
72- current_file_path = path .join (current_path , filename )
73- new_file_path = path .join (new_path , filename )
74- if path .exists (current_file_path ):
75- if not path .exists (new_file_path ):
76- copyfile (current_file_path , new_file_path )
77- else :
78- print (f"Skip { filename } : update contains same file" )
79- else :
80- print (f"Skip { filename } : no such file" )
81-
82- except Exception as e :
83- print ("Failed to copy previous version data:" , e )
84- print ("You may do this manually, from" , backup_filename )
85- print ("Files to copy:" , copy_list )
86-
8760
8861def configure (binder : inject .Binder ):
8962 # Couple of components
9063 # Handled at runtime
9164 config_manager = ConfigFileManager ("config" )
65+ binder .bind (ConfigFileManager , config_manager )
9266 binder .bind (ConfigObj , config_manager .config )
9367
9468 inversion_rules = InversionRulesController ()
0 commit comments