Fix path fetching for Tracks.

This commit is contained in:
Joshua Strobl 2021-06-29 12:57:52 +03:00
parent 44e4564f1c
commit 269f422b63
3 changed files with 15 additions and 12 deletions

View file

@ -273,7 +273,7 @@ void koto_config_load(
if (create_err != NULL) { if (create_err != NULL) {
if (create_err->code != G_IO_ERROR_EXISTS) { // Not an error indicating the file already exists 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; return;
} }
} }

View file

@ -361,7 +361,7 @@ void koto_library_set_storage_uuid(
} }
if (g_mount_is_shadowed(mount)) { // Is shadowed and should not use 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; return;
} }

View file

@ -353,21 +353,24 @@ gchar * koto_track_get_path(KotoTrack * self) {
return NULL; return NULL;
} }
GList * libs = koto_cartographer_get_libraries(koto_maps); // Get all of our libraries GHashTableIter iter;
GList * cur_lib_list;
for (cur_lib_list = libs; cur_lib_list != NULL; cur_lib_list = libs->next) { // Iterate over our libraries g_hash_table_iter_init(&iter, self->paths); // Create an iterator for our paths
KotoLibrary * cur_library = libs->data; // Get this as a KotoLibrary gpointer uuidptr;
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 gpointer relpathptr;
if (!koto_utils_is_string_valid(library_relative_path)) { // Not a valid path gchar * path = NULL;
continue;
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) { guint koto_track_get_position(KotoTrack * self) {