Improve handling of 'broken' playlists

This commit is contained in:
jdgleaver 2020-04-07 12:00:16 +01:00
parent b01aabf7d1
commit ad8a1174f7
6 changed files with 74 additions and 34 deletions

View File

@ -1211,9 +1211,13 @@ static bool menu_content_playlist_load(playlist_t *playlist, size_t idx)
char path[PATH_MAX_LENGTH];
const struct playlist_entry *entry = NULL;
path[0] = '\0';
playlist_get_index(playlist, idx, &entry);
path[0] = '\0';
if (!entry || string_is_empty(entry->path))
return false;
strlcpy(path, entry->path, sizeof(path));
playlist_resolve_path(PLAYLIST_LOAD, path, sizeof(path));
@ -2074,9 +2078,13 @@ static int action_ok_playlist_entry_collection(const char *path,
return 1;
}
/* Is the core path / name of the playlist entry not yet filled in? */
if ( string_is_equal(entry->core_path, "DETECT")
&& string_is_equal(entry->core_name, "DETECT"))
/* Check whether playlist already has core path/name
* assignments
* > Both core name and core path must be valid */
if ( string_is_empty(entry->core_path)
|| string_is_empty(entry->core_name)
|| string_is_equal(entry->core_path, "DETECT")
|| string_is_equal(entry->core_name, "DETECT"))
{
core_info_ctx_find_t core_info;
const char *entry_path = NULL;
@ -2127,7 +2135,7 @@ static int action_ok_playlist_entry_collection(const char *path,
else
{
strlcpy(new_core_path, entry->core_path, sizeof(new_core_path));
playlist_resolve_path(PLAYLIST_LOAD, new_core_path, sizeof(new_core_path));
playlist_resolve_path(PLAYLIST_LOAD, new_core_path, sizeof(new_core_path));
}
if (!playlist || !menu_content_playlist_load(playlist, selection_ptr))
@ -2172,8 +2180,13 @@ static int action_ok_playlist_entry(const char *path,
entry_label = entry->label;
if ( string_is_equal(entry->core_path, "DETECT")
&& string_is_equal(entry->core_name, "DETECT"))
/* Check whether playlist already has core path/name
* assignments
* > Both core name and core path must be valid */
if ( string_is_empty(entry->core_path)
|| string_is_empty(entry->core_name)
|| string_is_equal(entry->core_path, "DETECT")
|| string_is_equal(entry->core_name, "DETECT"))
{
core_info_ctx_find_t core_info;
const char *default_core_path =
@ -2212,7 +2225,7 @@ static int action_ok_playlist_entry(const char *path,
}
}
else if (!string_is_empty(entry->core_path))
else
{
strlcpy(new_core_path, entry->core_path, sizeof(new_core_path));
playlist_resolve_path(PLAYLIST_LOAD, new_core_path, sizeof(new_core_path));
@ -2251,8 +2264,13 @@ static int action_ok_playlist_entry_start_content(const char *path,
playlist_get_index(playlist, selection_ptr, &entry);
if ( string_is_equal(entry->core_path, "DETECT")
&& string_is_equal(entry->core_name, "DETECT"))
/* Check whether playlist already has core path/name
* assignments
* > Both core name and core path must be valid */
if ( string_is_empty(entry->core_path)
|| string_is_empty(entry->core_name)
|| string_is_equal(entry->core_path, "DETECT")
|| string_is_equal(entry->core_name, "DETECT"))
{
core_info_ctx_find_t core_info;
char new_core_path[PATH_MAX_LENGTH];

View File

@ -475,7 +475,8 @@ static int action_right_video_resolution(unsigned type, const char *label,
static int playlist_association_right(unsigned type, const char *label,
bool wraparound)
{ char core_path[PATH_MAX_LENGTH];
{
char core_path[PATH_MAX_LENGTH];
size_t i, next, current = 0;
core_info_list_t *core_info_list = NULL;
core_info_t *core_info = NULL;

View File

@ -1103,9 +1103,12 @@ static int action_bind_sublabel_playlist_entry(
/* Read playlist entry */
playlist_get_index(playlist, i, &entry);
/* Only add sublabel if a core is currently assigned */
/* Only add sublabel if a core is currently assigned
* > Both core name and core path must be valid */
if ( string_is_empty(entry->core_name) ||
string_is_equal(entry->core_name, "DETECT"))
string_is_equal(entry->core_name, "DETECT") ||
string_is_empty(entry->core_path) ||
string_is_equal(entry->core_path, "DETECT"))
return 0;
/* Add core name */

View File

@ -965,7 +965,9 @@ static int menu_displaylist_parse_playlist(menu_displaylist_info_t *info,
if (show_inline_core_name)
{
if (!string_is_empty(entry->core_name) && !string_is_equal(entry->core_name, "DETECT"))
/* Both core name and core path must be valid */
if (!string_is_empty(entry->core_name) && !string_is_equal(entry->core_name, "DETECT") &&
!string_is_empty(entry->core_path) && !string_is_equal(entry->core_path, "DETECT"))
{
strlcat(menu_entry_label, label_spacer, sizeof(menu_entry_label));
strlcat(menu_entry_label, entry->core_name, sizeof(menu_entry_label));
@ -977,11 +979,19 @@ static int menu_displaylist_parse_playlist(menu_displaylist_info_t *info,
}
else
{
if (entry->core_name)
/* Playlist entry without content...
* This is useless/broken, but have to include
* it otherwise synchronisation between the menu
* and the underlying playlist will be lost...
* > Use label if available, otherwise core name
* > If both are missing, add an empty menu entry */
if (!string_is_empty(entry->label))
strlcpy(menu_entry_label, entry->label, sizeof(menu_entry_label));
else if (!string_is_empty(entry->core_name))
strlcpy(menu_entry_label, entry->core_name, sizeof(menu_entry_label));
menu_entries_append_enum(info->list, menu_entry_label, path_playlist,
MENU_ENUM_LABEL_PLAYLIST_ENTRY, FILE_TYPE_PLAYLIST_ENTRY, 0, i);
MENU_ENUM_LABEL_PLAYLIST_ENTRY, FILE_TYPE_RPL_ENTRY, 0, i);
}
info->count++;
@ -3086,7 +3096,12 @@ static unsigned menu_displaylist_parse_content_information(
core_path = entry->core_path;
db_name = entry->db_name;
strlcpy(core_name, entry->core_name, sizeof(core_name));
/* Only display core name if both core name and
* core path are valid */
if (!string_is_empty(entry->core_name) &&
!string_is_empty(core_path) &&
!string_is_equal(core_path, "DETECT"))
strlcpy(core_name, entry->core_name, sizeof(core_name));
}
}
else

View File

@ -2450,36 +2450,38 @@ static int playlist_qsort_func(const struct playlist_entry *a,
* have no other option...) */
if (string_is_empty(a_str))
{
if (string_is_empty(a->path))
goto end;
a_fallback_label = (char*)calloc(PATH_MAX_LENGTH, sizeof(char));
if (!a_fallback_label)
goto end;
fill_short_pathname_representation(a_fallback_label, a->path, PATH_MAX_LENGTH * sizeof(char));
if (!string_is_empty(a->path))
fill_short_pathname_representation(a_fallback_label, a->path, PATH_MAX_LENGTH * sizeof(char));
/* If filename is also empty, use core name
* instead -> this matches the behaviour of
* menu_displaylist_parse_playlist() */
else if (!string_is_empty(a->core_name))
strlcpy(a_fallback_label, a->core_name, PATH_MAX_LENGTH * sizeof(char));
if (string_is_empty(a_fallback_label))
goto end;
/* If both filename and core name are empty,
* then have to compare an empty string
* -> again, this is to match the behaviour of
* menu_displaylist_parse_playlist() */
a_str = a_fallback_label;
}
if (string_is_empty(b_str))
{
if (string_is_empty(b->path))
goto end;
b_fallback_label = (char*)calloc(PATH_MAX_LENGTH, sizeof(char));
if (!b_fallback_label)
goto end;
fill_short_pathname_representation(b_fallback_label, b->path, PATH_MAX_LENGTH * sizeof(char));
if (string_is_empty(b_fallback_label))
goto end;
if (!string_is_empty(b->path))
fill_short_pathname_representation(b_fallback_label, b->path, PATH_MAX_LENGTH * sizeof(char));
else if (!string_is_empty(b->core_name))
strlcpy(b_fallback_label, b->core_name, PATH_MAX_LENGTH * sizeof(char));
b_str = b_fallback_label;
}

View File

@ -298,16 +298,17 @@ runtime_log_t *runtime_log_init(
return NULL;
}
if ( string_is_empty(core_path) ||
string_is_equal(core_path, "builtin") ||
string_is_equal(core_path, "DETECT"))
return NULL;
core_path_basename = path_basename(core_path);
if ( string_is_empty(content_path) ||
string_is_empty(core_path_basename))
return NULL;
if ( string_is_equal(core_path, "builtin") ||
string_is_equal(core_path, "DETECT"))
return NULL;
/* Get core name
* Note: An annoyance - this is required even when
* we are performing aggregate (not per core) logging,