do not push entries that are already on the database

This commit is contained in:
radius 2016-01-26 15:21:01 -05:00
parent 68ea128cb5
commit 2af0708047
3 changed files with 25 additions and 5 deletions

View File

@ -116,6 +116,21 @@ void content_playlist_get_index_by_path(content_playlist_t *playlist,
}
bool content_playlist_entry_exists(content_playlist_t *playlist,
const char *path,
const char *crc32)
{
size_t i;
if (!playlist)
return false;
for (i = 0; i < playlist->size; i++)
if (string_is_equal(playlist->entries[i].path, path) || string_is_equal(playlist->entries[i].crc32, crc32))
return true;
return false;
}
/**
* content_playlist_free_entry:
* @entry : Playlist entry handle.

View File

@ -113,6 +113,10 @@ void content_playlist_get_index_by_path(content_playlist_t *playlist,
char **db_name,
char **crc32);
bool content_playlist_entry_exists(content_playlist_t *playlist,
const char *path,
const char *crc32);
void content_playlist_write_file(content_playlist_t *playlist);
void content_playlist_qsort(content_playlist_t *playlist, content_playlist_sort_fun_t *fn);

View File

@ -184,7 +184,6 @@ static int database_info_iterate_playlist(
memset(&db->state, 0, sizeof(file_archive_transfer_t));
db_state->zip_name[0] = '\0';
db->state.type = ZLIB_TRANSFER_INIT;
return 1;
#endif
case HASH_EXTENSION_CUE:
@ -304,16 +303,19 @@ static int database_info_list_iterate_found_match(
RARCH_LOG("entry path str: %s\n", entry_path_str);
#endif
content_playlist_push(playlist, entry_path_str,
db_info_entry->name, "DETECT", "DETECT", db_crc, db_playlist_base_str);
if(!content_playlist_entry_exists(playlist, entry_path_str, db_crc))
{
content_playlist_push(playlist, entry_path_str,
db_info_entry->name, "DETECT", "DETECT", db_crc, db_playlist_base_str);
}
content_playlist_write_file(playlist);
content_playlist_free(playlist);
database_info_list_free(db_state->info);
printf("SCANNING: %d %s\n", db_state->crc, db_playlist_path);
db_state->info = NULL;
db_state->crc = 0;
return 0;
}
@ -480,7 +482,6 @@ static int database_info_iterate(database_state_handle_t *db_state, database_inf
case DATABASE_TYPE_CRC_LOOKUP:
return database_info_iterate_crc_lookup(db_state, db, NULL);
}
return 0;
}