Skip to content

Commit

Permalink
Strict matching works.
Browse files Browse the repository at this point in the history
  • Loading branch information
zoltanvb committed Feb 1, 2025
1 parent 623bd62 commit 35e16c8
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 33 deletions.
22 changes: 4 additions & 18 deletions core_updater_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -531,43 +531,29 @@ bool thumbnail_updater_list_get_filename(
/* Fetches thumbnail updater list entry corresponding
* to the specified thumbnail.
* Returns false if thumbnail is not found. */
bool thumbnail_updater_list_get_thumbnail(
bool thumbnail_updater_list_get_matching_file(
thumbnail_updater_list_t *thumbnail_list,
const char *local_thumbnail_path,
const thumbnail_updater_list_entry_t **entry)
{
bool resolve_symlinks;
size_t num_entries;
size_t i;
char real_thumbnail_path[PATH_MAX_LENGTH];

if (!thumbnail_list || !entry || string_is_empty(local_thumbnail_path))
if (!thumbnail_list || string_is_empty(local_thumbnail_path))
return false;
if ((num_entries = RBUF_LEN(thumbnail_list->entries)) < 1)
return false;

/* Resolve absolute pathname of local_thumbnail_path */
strlcpy(real_thumbnail_path, local_thumbnail_path, sizeof(real_thumbnail_path));

if (string_is_empty(real_thumbnail_path))
return false;

/* Search for specified thumbnail */
for (i = 0; i < num_entries; i++)
{
thumbnail_updater_list_entry_t *current_entry = &thumbnail_list->entries[i];

if (string_is_empty(current_entry->local_filename))
if (string_is_empty(current_entry->remote_filename))
continue;

#ifdef _WIN32
/* Handle case-insensitive operating systems*/
if (string_is_equal_noncase(real_thumbnail_path, current_entry->local_filename))
if (string_is_equal(local_thumbnail_path, current_entry->remote_filename))
{
#else
if (string_is_equal(real_thumbnail_path, current_entry->local_filename))
{
#endif
*entry = current_entry;
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion core_updater_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ bool thumbnail_updater_list_get_filename(
const char *remote_filename,
const thumbnail_updater_list_entry_t **entry);

bool thumbnail_updater_list_get_thumbnail(
bool thumbnail_updater_list_get_matching_file(
thumbnail_updater_list_t *thumbnail_list,
const char *local_thumbnail_path,
const thumbnail_updater_list_entry_t **entry);
Expand Down
43 changes: 29 additions & 14 deletions tasks/task_pl_thumbnail_download.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ enum pl_thumb_status
PL_THUMB_WAIT_INDEX,
PL_THUMB_ITERATE_ENTRY,
PL_THUMB_ITERATE_TYPE,
PL_THUMB_ITERATE_INTELLIGENT,
PL_THUMB_END
};

Expand Down Expand Up @@ -204,6 +203,7 @@ static bool task_pl_thumbnail_get_thumbnail_paths(
const char *sub_dir = NULL;
const char *system_name = NULL;
const char *system = NULL;
thumbnail_updater_list_t *thumbnail_list = NULL;

content_dir[0] = '\0';

Expand Down Expand Up @@ -260,9 +260,33 @@ static bool task_pl_thumbnail_get_thumbnail_paths(
raw_url[0] = '\0';

/* Generate remote path */
snprintf(raw_url, raw_url_len, "%s/%s/%s/%s",
FILE_PATH_CORE_THUMBNAILS_URL,
system_name, sub_dir, img_name);
thumbnail_list = thumbnail_updater_list_get_cached(system_name);
if (thumbnail_list)
{
const thumbnail_updater_list_entry_t *entry;
snprintf(raw_url, raw_url_len, "%s/%s", sub_dir, img_name);

RARCH_LOG("[Thumbnail]: Trying to find %s thumbnail for %s\n",system_name,raw_url);
if (thumbnail_updater_list_get_matching_file(
thumbnail_list, raw_url, &entry))
{
RARCH_LOG("[Thumbnail]: Found as %s\n",entry->remote_filename);
snprintf(raw_url, raw_url_len, "%s/%s/%s",
FILE_PATH_CORE_THUMBNAILS_URL,
system_name, entry->remote_filename);
}
else
{
raw_url[0] = '\0';
RARCH_LOG("[Thumbnail]: Not found in %d entries.\n",thumbnail_updater_list_size(thumbnail_list));
}
}
else
{
snprintf(raw_url, raw_url_len, "%s/%s/%s/%s",
FILE_PATH_CORE_THUMBNAILS_URL,
system_name, sub_dir, img_name);
}

if (string_is_empty(raw_url))
{
Expand Down Expand Up @@ -706,18 +730,9 @@ static void task_pl_thumbnail_download_handler(retro_task_t *task)
find_data.userdata = (void*)thumbnail_list;

if (!task_queue_find(&find_data))
{
/* If index retrieval was unsuccessful, fall back to old method */
if (thumbnail_updater_list_is_empty(pl_thumb->system))
pl_thumb->status = PL_THUMB_ITERATE_ENTRY;
else
pl_thumb->status = PL_THUMB_ITERATE_INTELLIGENT;
}
pl_thumb->status = PL_THUMB_ITERATE_ENTRY;
break;
}
case PL_THUMB_ITERATE_INTELLIGENT:
pl_thumb->status = PL_THUMB_END;
break;
case PL_THUMB_ITERATE_ENTRY:
/* Set current thumbnail content */
if (gfx_thumbnail_set_content_playlist(
Expand Down

0 comments on commit 35e16c8

Please sign in to comment.