@@ -361,7 +361,7 @@ def activate_instance(port=2001, default_timeout=0.5, to_port=2004):
361361 all_tracks , all_tracks_sorted = {}, []
362362 url_metadata : dict (URLMetadata ) = {}
363363 tray_playlists = [t ('Playlists Tab' )]
364- CHECK_MARK = '✓ '
364+ CHECK_MARK = '✓ '
365365 music_folders , device_names = [], [(f'{ CHECK_MARK } ' + t ('Local device' ), 'device:0' )]
366366 music_queue , done_queue , next_queue = deque (), deque (), deque ()
367367 # usage: background_thread sleep(1) if seek_queue, seek_queue.pop(), seek_queue.clear(), call set_pos
@@ -461,6 +461,9 @@ def save_settings():
461461 # this atomic operation ensures that a settings.file will exist if the system crashes before/after the system call
462462 os .replace (tmp_file .name , SETTINGS_FILE )
463463 settings_last_modified = os .path .getmtime (SETTINGS_FILE )
464+ except Exception as e :
465+ handle_exception (e )
466+ tray_notify (t ('ERROR' ) + f': { e } ' )
464467 except OSError as e :
465468 if e .errno == errno .ENOSPC :
466469 tray_notify (t ('ERROR' ) + ': ' + t ('No space left on device to save settings' ))
@@ -862,8 +865,16 @@ def load_settings(first_load=False): # up to 0.4 seconds
862865 _save_settings = False
863866 with settings_file_lock :
864867 try :
865- with open (SETTINGS_FILE , encoding = 'utf-8' ) as json_file :
866- loaded_settings = json .load (json_file )
868+ attempt = 0
869+ while True :
870+ try :
871+ with open (SETTINGS_FILE , encoding = 'utf-8' ) as json_file :
872+ loaded_settings = json .load (json_file )
873+ break
874+ except PermissionError :
875+ attempt += 1
876+ if attempt == 10 :
877+ raise
867878 except (FileNotFoundError , ValueError ):
868879 # if file does not exist
869880 _save_settings = True
0 commit comments