Skip to content

Commit 5f27a25

Browse files
committed
Try fixing save/load settings file
1 parent 0dfcae5 commit 5f27a25

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

CHANGELOG.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
Music Caster Changelog
22

3+
5.25.1
4+
- [Fix] Settings save/load ?
5+
36
5.25.0
47
- [Fix] Forwards compatibility for v6
58
- [Fix] Maintenance (Python 3.14)

src/meta.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION = latest_version = '5.25.0'
1+
VERSION = latest_version = '5.25.1'
22
UPDATE_MESSAGE = """
33
[NEW] Support "System Audio" in CLI
44
[MSG] Language translators wanted

src/music_caster.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)