From b83504635cce92e6d4fffce0c51b9acdffca5df8 Mon Sep 17 00:00:00 2001 From: Christian Soffke Date: Thu, 9 Jan 2025 23:33:46 +0100 Subject: [PATCH] playlist: eliminate error message disconnecting USB With no control file present, the message "Error accessing playlist control file" was displayed, due to playlist_resume being called from gui_usb_screen_run. You were likely to only run into this after a clean install, if you hadn't listened to any music yet. It probably makes sense to move the check for the existence of the control file into playlist_resume, and not even have it show a separate access error message when the file doesn't exist. Change-Id: Ib3a643c43d3d4d499fa5a13c01955779d69cd357 --- apps/menus/playlist_menu.c | 2 +- apps/playlist.c | 3 +++ apps/playlist_viewer.c | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/menus/playlist_menu.c b/apps/menus/playlist_menu.c index 4e01b29103..a4d91ceb10 100644 --- a/apps/menus/playlist_menu.c +++ b/apps/menus/playlist_menu.c @@ -56,7 +56,7 @@ int save_playlist_screen(struct playlist_info* playlist) catalogue's context menu in root menu */ if (!playlist && audio_stopped && !playlist_get_current()->started) { - if (!file_exists(PLAYLIST_CONTROL_FILE) || playlist_resume() == -1) + if (playlist_resume() == -1) { splash(HZ, ID2P(LANG_CATALOG_NO_PLAYLISTS)); return 0; diff --git a/apps/playlist.c b/apps/playlist.c index 5a9027fd9d..a33c19a1e4 100644 --- a/apps/playlist.c +++ b/apps/playlist.c @@ -3176,6 +3176,9 @@ int playlist_resume(void) empty_playlist_unlocked(playlist, true); + if (!file_exists(playlist->control_filename)) + goto out; + playlist->control_fd = open(playlist->control_filename, O_RDWR); if (playlist->control_fd < 0) { diff --git a/apps/playlist_viewer.c b/apps/playlist_viewer.c index 4426d0da81..3cb1047583 100644 --- a/apps/playlist_viewer.c +++ b/apps/playlist_viewer.c @@ -387,7 +387,7 @@ static bool playlist_viewer_init(struct playlist_viewer * viewer, if (!filename && !is_playing) { /* Try to restore the list from control file */ - if (!file_exists(PLAYLIST_CONTROL_FILE) || playlist_resume() == -1) + if (playlist_resume() == -1) { /* Nothing to view, exit */ splash(HZ, ID2P(LANG_CATALOG_NO_PLAYLISTS));