Create database_info_set_type

This commit is contained in:
twinaphex 2016-09-29 10:43:38 +02:00
parent fc3c17547e
commit 7e1639f33b
3 changed files with 15 additions and 6 deletions

View File

@ -655,6 +655,13 @@ void database_info_list_free(database_info_list_t *database_info_list)
free(database_info_list->list);
}
void database_info_set_type(database_info_handle_t *handle, enum database_type type)
{
if (!handle)
return;
handle->type = type;
}
enum database_type database_info_get_type(database_info_handle_t *handle)
{
if (!handle)

View File

@ -108,6 +108,8 @@ database_info_handle_t *database_info_dir_init(const char *dir,
database_info_handle_t *database_info_file_init(const char *path,
enum database_type type);
void database_info_set_type(database_info_handle_t *handle, enum database_type type);
enum database_type database_info_get_type(database_info_handle_t *handle);
void database_info_free(database_info_handle_t *handle);

View File

@ -165,7 +165,7 @@ static int task_database_iterate_playlist(
{
case FILE_TYPE_COMPRESSED:
#ifdef HAVE_COMPRESSION
db->type = DATABASE_TYPE_CRC_LOOKUP;
database_info_set_type(db, DATABASE_TYPE_CRC_LOOKUP);
/* first check crc of archive itself */
return file_get_crc(db_state, name, &db_state->archive_crc);
#else
@ -174,18 +174,18 @@ static int task_database_iterate_playlist(
case FILE_TYPE_CUE:
db_state->serial[0] = '\0';
cue_get_serial(db_state, db, name, db_state->serial);
db->type = DATABASE_TYPE_SERIAL_LOOKUP;
database_info_set_type(db, DATABASE_TYPE_SERIAL_LOOKUP);
break;
case FILE_TYPE_ISO:
db_state->serial[0] = '\0';
iso_get_serial(db_state, db, name, db_state->serial);
db->type = DATABASE_TYPE_SERIAL_LOOKUP;
database_info_set_type(db, DATABASE_TYPE_SERIAL_LOOKUP);
break;
case FILE_TYPE_LUTRO:
db->type = DATABASE_TYPE_ITERATE_LUTRO;
database_info_set_type(db, DATABASE_TYPE_ITERATE_LUTRO);
break;
default:
db->type = DATABASE_TYPE_CRC_LOOKUP;
database_info_set_type(db, DATABASE_TYPE_CRC_LOOKUP);
return file_get_crc(db_state, name, &db_state->crc);
}
@ -503,7 +503,7 @@ static int task_database_iterate(database_state_handle_t *db_state,
if (database_info_get_type(db) == DATABASE_TYPE_ITERATE)
if (path_contains_compressed_file(name))
db->type = DATABASE_TYPE_ITERATE_ARCHIVE;
database_info_set_type(db, DATABASE_TYPE_ITERATE_ARCHIVE);
switch (database_info_get_type(db))
{