@@ -776,12 +776,45 @@ def reset_cloud_folder(w):
776776 # enable or disable the response of this dialog in depending on the selected periodic synchronization interval
777777 def on_psync_changed (psyncRow , GParamObject ):
778778 self .cloudDialog .set_response_enabled ('ok' , not (self .psyncRow .get_selected_item ().get_string () == _ ["never" ] or not self .cfileRow .get_subtitle ()))
779+
780+ def finish_setup ():
781+ if self .cfileRow .get_subtitle ():
782+ # check if the selected periodic sync interval was Never: if yes, shows the message about the necessity to log out of the system
783+ if self .check_psync == "Never2" :
784+ if not settings ["periodic-import" ] == "Never2" :
785+ self .show_warn_toast ()
786+
787+ # if it is selected to manually sync, it creates an option in the app menu in the header bar
788+ if settings ["manually-sync" ]:
789+ self .sync_menu = Gio .Menu ()
790+ self .sync_menu .append (_ ["sync" ], 'app.m-sync-with-key' )
791+ self .main_menu .prepend_section (None , self .sync_menu )
792+ self .show_special_toast ()
793+ else :
794+ try :
795+ self .sync_menu .remove_all ()
796+ except :
797+ pass
798+
799+ def check_fs ():
800+ try :
801+ check_filesystem = subprocess .getoutput ('df -T "%s" | awk \' NR==2 {print $2}\' ' % self .cfileRow .get_subtitle ())
802+ if ("gvfsd" not in check_filesystem and "rclone" not in check_filesystem ) and not os .path .exists (f"{ settings ['periodic-saving-folder' ]} /.stfolder" ):
803+ os .system (f"notify-send \" { _ ['err_occured' ]} \" \" { _ ['cloud_folder_err' ]} \" " )
804+ settings ["file-for-syncing" ] = ""
805+ else :
806+ settings ["file-for-syncing" ] = self .cfileRow .get_subtitle ()
807+ except Exception as e :
808+ print (e )
809+ finally :
810+ self .mount_type = "cloud-receiver"
811+ self .set_up_auto_mount ()
812+ GLib .idle_add (finish_setup )
779813
780814 # Action after closing URL dialog
781815 def cloudDialog_closed (w , response ):
782816 if response == 'ok' :
783- check_psync = settings ["periodic-import" ]
784-
817+ self .check_psync = settings ["periodic-import" ]
785818 # translate the periodic sync options to English
786819 selected_item = self .psyncRow .get_selected_item ()
787820 sync = {_ ["never" ]: "Never2" , _ ["manually" ]: "Manually2" , _ ["daily" ]: "Daily2" , _ ["weekly" ]: "Weekly2" , _ ["monthly" ]: "Monthly2" }
@@ -796,37 +829,8 @@ def cloudDialog_closed(w, response):
796829 # save the status of the Bidirectional Synchronization switch
797830 settings ["bidirectional-sync" ] = self .bsSwitch .get_active ()
798831
799- check_filesystem = subprocess .getoutput ('df -T "%s" | awk \' NR==2 {print $2}\' ' % self .cfileRow .get_subtitle ())
800-
801- if self .cfileRow .get_subtitle ():
802- # Check if the selected cloud drive folder is correct
803- if ("gvfsd" not in check_filesystem and "rclone" not in check_filesystem ) and not os .path .exists (f"{ settings ['periodic-saving-folder' ]} /.stfolder" ):
804- os .system (f"notify-send \" { _ ['err_occured' ]} \" \" { _ ['cloud_folder_err' ]} \" " )
805- settings ["file-for-syncing" ] = ""
806- else :
807- settings ["file-for-syncing" ] = self .cfileRow .get_subtitle ()
808-
809- # check if the selected periodic sync interval was Never: if yes, shows the message about the necessity to log out of the system
810- if check_psync == "Never2" :
811- if not settings ["periodic-import" ] == "Never2" :
812- self .show_warn_toast ()
813-
814- # if it is selected to manually sync, it creates an option in the app menu in the header bar
815- if settings ["manually-sync" ]:
816- self .sync_menu = Gio .Menu ()
817- self .sync_menu .append (_ ["sync" ], 'app.m-sync-with-key' )
818- self .main_menu .prepend_section (None , self .sync_menu )
819- self .show_special_toast ()
820- else :
821- try :
822- self .sync_menu .remove_all ()
823- except :
824- pass
825-
826- self .mount_type = "cloud-receiver"
827- self .set_up_auto_mount ()
828- else :
829- pass
832+ check_thread = Thread (target = check_fs )
833+ check_thread .start ()
830834
831835 # Dialog itself
832836 self .cloudDialog = Adw .AlertDialog .new ()
0 commit comments