From 2af07080479cbaf7a8cbb72edb0573c3a2e8172d Mon Sep 17 00:00:00 2001 From: radius Date: Tue, 26 Jan 2016 15:21:01 -0500 Subject: [PATCH] do not push entries that are already on the database --- playlist.c | 15 +++++++++++++++ playlist.h | 4 ++++ tasks/task_database.c | 11 ++++++----- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/playlist.c b/playlist.c index 179a3d79a5..ab5824a430 100644 --- a/playlist.c +++ b/playlist.c @@ -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. diff --git a/playlist.h b/playlist.h index 570882fa6b..83e84ddcc6 100644 --- a/playlist.h +++ b/playlist.h @@ -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); diff --git a/tasks/task_database.c b/tasks/task_database.c index 4b9f6bc8fc..698f3e082d 100644 --- a/tasks/task_database.c +++ b/tasks/task_database.c @@ -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; }