skip scanning of compressed files within archives if the core attached to this database supports archive files themselves

This commit is contained in:
Brad Parker 2016-10-12 16:14:00 -04:00
parent 2fe10a0a23
commit 88c8c49ef8
2 changed files with 62 additions and 11 deletions

View File

@ -691,15 +691,37 @@ size_t core_info_list_num_info_files(core_info_list_t *core_info_list)
bool core_info_unsupported_content_path(const char *path)
{
size_t i;
const char *delim;
const char *archive_path = NULL;
delim = path_get_archive_delim(path);
if (delim)
archive_path = delim - 1;
if (!core_info_curr_list)
return false;
/* if the path contains a compressed file and the core supports archives,
* we don't want to look at this file */
if (archive_path)
{
for (i = 0; i < core_info_curr_list->count; i++)
{
const core_info_t *info = &core_info_curr_list->list[i];
if (string_list_find_elem(info->supported_extensions_list, "zip") ||
string_list_find_elem(info->supported_extensions_list, "7z"))
return false;
}
}
for (i = 0; i < core_info_curr_list->count; i++)
{
const core_info_t *info = &core_info_curr_list->list[i];
bool path_in_ext_list = string_list_find_elem(info->supported_extensions_list, path_get_extension(path));
if (string_list_find_elem(info->supported_extensions_list, path_get_extension(path)))
if (path_in_ext_list)
return false;
}
@ -709,7 +731,9 @@ bool core_info_unsupported_content_path(const char *path)
bool core_info_database_supports_content_path(const char *database_path, const char *path)
{
size_t i;
char *database = NULL;
char *database;
const char *delim;
const char *archive_path = NULL;
if (!core_info_curr_list)
return false;
@ -718,16 +742,38 @@ bool core_info_database_supports_content_path(const char *database_path, const c
path_remove_extension(database);
delim = path_get_archive_delim(path);
if (delim)
archive_path = delim - 1;
/* if the path contains a compressed file and the core supports archives,
* we don't want to look at this file */
if (archive_path)
{
for (i = 0; i < core_info_curr_list->count; i++)
{
const core_info_t *info = &core_info_curr_list->list[i];
if (string_list_find_elem(info->supported_extensions_list, "zip") ||
string_list_find_elem(info->supported_extensions_list, "7z"))
return false;
}
}
for (i = 0; i < core_info_curr_list->count; i++)
{
const core_info_t *info = &core_info_curr_list->list[i];
bool path_in_ext_list = string_list_find_elem(info->supported_extensions_list, path_get_extension(path));
if (string_list_find_elem(info->supported_extensions_list, path_get_extension(path)))
if (path_in_ext_list)
{
if (string_list_find_elem(info->databases_list, database))
{
free(database);
return true;
}
}
}
free(database);

View File

@ -114,7 +114,7 @@ static int cue_get_serial(database_state_handle_t *db_state,
int rv = 0;
track_path[0] = '\0';
rv = find_first_data_track(name,
&offset, track_path, PATH_MAX_LENGTH);
@ -240,9 +240,9 @@ static int database_info_list_iterate_found_match(
char entry_path_str[PATH_MAX_LENGTH];
playlist_t *playlist = NULL;
settings_t *settings = config_get_ptr();
const char *db_path =
const char *db_path =
database_info_get_current_name(db_state);
const char *entry_path =
const char *entry_path =
database_info_get_current_element_name(db);
database_info_t *db_info_entry =
&db_state->info->list[db_state->entry_index];
@ -335,12 +335,17 @@ static int task_database_iterate_crc_lookup(
if (db_state->entry_index == 0)
{
bool db_supports_content;
bool unsupported_content;
char query[50];
query[0] = '\0';
if (!core_info_database_supports_content_path(db_state->list->elems[db_state->list_index].data, name) &&
!core_info_unsupported_content_path(name))
db_supports_content = core_info_database_supports_content_path(db_state->list->elems[db_state->list_index].data, name);
unsupported_content = core_info_unsupported_content_path(name);
/* don't scan files that can't be in this database */
if(!db_supports_content && !unsupported_content)
return database_info_list_iterate_next(db_state);
snprintf(query, sizeof(query),
@ -557,10 +562,10 @@ static void task_database_handler(retro_task_t *task)
database_info_handle_t *dbinfo = NULL;
database_state_handle_t *dbstate = NULL;
db_handle_t *db = NULL;
if (!task)
goto task_finished;
db = (db_handle_t*)task->state;
if (!db)
@ -568,7 +573,7 @@ static void task_database_handler(retro_task_t *task)
dbinfo = db->handle;
dbstate = &db->state;
if (!dbinfo || task->cancelled)
goto task_finished;