From 269f422b636c88f2ec5402b9d06ea8f4ab80059e Mon Sep 17 00:00:00 2001 From: Joshua Strobl Date: Tue, 29 Jun 2021 12:57:52 +0300 Subject: [PATCH] Fix path fetching for Tracks. --- src/config/config.c | 2 +- src/indexer/library.c | 2 +- src/indexer/track.c | 23 +++++++++++++---------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/config/config.c b/src/config/config.c index b034c0f..b441cc3 100644 --- a/src/config/config.c +++ b/src/config/config.c @@ -273,7 +273,7 @@ void koto_config_load( if (create_err != NULL) { if (create_err->code != G_IO_ERROR_EXISTS) { // Not an error indicating the file already exists - g_message("Failed to create or open file: %s", create_err->message); + g_warning("Failed to create or open file: %s", create_err->message); return; } } diff --git a/src/indexer/library.c b/src/indexer/library.c index 410a1d2..97a1d67 100644 --- a/src/indexer/library.c +++ b/src/indexer/library.c @@ -361,7 +361,7 @@ void koto_library_set_storage_uuid( } if (g_mount_is_shadowed(mount)) { // Is shadowed and should not use - g_message("This mount is considered \"shadowed\" and will not be used."); + g_warning("This mount is considered \"shadowed\" and will not be used."); return; } diff --git a/src/indexer/track.c b/src/indexer/track.c index 668e0b2..d25166e 100644 --- a/src/indexer/track.c +++ b/src/indexer/track.c @@ -353,21 +353,24 @@ gchar * koto_track_get_path(KotoTrack * self) { return NULL; } - GList * libs = koto_cartographer_get_libraries(koto_maps); // Get all of our libraries - GList * cur_lib_list; + GHashTableIter iter; - for (cur_lib_list = libs; cur_lib_list != NULL; cur_lib_list = libs->next) { // Iterate over our libraries - KotoLibrary * cur_library = libs->data; // Get this as a KotoLibrary - gchar * library_relative_path = g_hash_table_lookup(self->paths, koto_library_get_uuid(cur_library)); // Get any relative path in our paths based on the current UUID + g_hash_table_iter_init(&iter, self->paths); // Create an iterator for our paths + gpointer uuidptr; + gpointer relpathptr; - if (!koto_utils_is_string_valid(library_relative_path)) { // Not a valid path - continue; + gchar * path = NULL; + + while (g_hash_table_iter_next(&iter, &uuidptr, &relpathptr)) { // Iterate over all the paths for this file + KotoLibrary * library = koto_cartographer_get_library_by_uuid(koto_maps, (gchar *) uuidptr); + + if (KOTO_IS_LIBRARY(library)) { + path = g_strdup(g_build_path(G_DIR_SEPARATOR_S, koto_library_get_path(library), koto_library_get_relative_path_to_file(library, (gchar *) relpathptr), NULL)); // Build our full library path using library's path and our file relative path + break; } - - return g_strdup(g_build_path(G_DIR_SEPARATOR_S, koto_library_get_path(cur_library), library_relative_path, NULL)); // Build our full library path using library's path and our file relative path } - return NULL; + return path; } guint koto_track_get_position(KotoTrack * self) {