[grilo-plugins/wip/jfelder/tracker3-empty-values] tracker3: Do not writeback empty values




commit 97703f30d2adbeee7fbe0164976aa18195f3cbd6
Author: Jean Felder <jfelder src gnome org>
Date:   Thu Aug 5 17:45:54 2021 +0200

    tracker3: Do not writeback empty values
    
    When setting properties that can have multiple values, it iterates
    until a null value is found. This last value should not be used to
    create a Tracker resource.

 src/tracker3/grl-tracker-utils.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/src/tracker3/grl-tracker-utils.c b/src/tracker3/grl-tracker-utils.c
index 53aef814..e7a6493a 100644
--- a/src/tracker3/grl-tracker-utils.c
+++ b/src/tracker3/grl-tracker-utils.c
@@ -667,8 +667,10 @@ grl_tracker_build_resource_from_media (GrlMedia *media, GList *keys)
 
       for (i = 0; artist_name != NULL; i++) {
         artist_name = grl_media_get_artist_nth (media, i);
-        artist = ensure_resource_for_property (resource, "nmm:artist", TRUE);
-        tracker_resource_set_string (artist, "nmm:artistName", artist_name);
+       if (artist_name) {
+         artist = ensure_resource_for_property (resource, "nmm:artist", TRUE);
+         tracker_resource_set_string (artist, "nmm:artistName", artist_name);
+       }
 
         /* Handle MB artist inline */
         if (g_list_find (keys, GRLKEYID_TO_POINTER (GRL_METADATA_KEY_MB_ARTIST_ID))) {
@@ -689,8 +691,10 @@ grl_tracker_build_resource_from_media (GrlMedia *media, GList *keys)
 
       for (i = 0; artist_name != NULL; i++) {
         artist_name = grl_media_get_artist_nth (media, i);
-        artist = ensure_resource_for_property (resource, "nmm:artist", TRUE);
-        tracker_resource_set_string (artist, "nmm:artistName", artist_name);
+       if (artist_name) {
+         artist = ensure_resource_for_property (resource, "nmm:artist", TRUE);
+         tracker_resource_set_string (artist, "nmm:artistName", artist_name);
+       }
       }
     } else if (l->data == GRLKEYID_TO_POINTER (GRL_METADATA_KEY_COMPOSER)) {
       TrackerResource *composer;
@@ -699,8 +703,10 @@ grl_tracker_build_resource_from_media (GrlMedia *media, GList *keys)
 
       for (i = 0; composer_name != NULL; i++) {
         composer_name = grl_media_get_composer_nth (media, i);
-        composer = ensure_resource_for_property (resource, "nmm:composer", TRUE);
-        tracker_resource_set_string (composer, "nmm:artistName", composer_name);
+       if (composer_name) {
+         composer = ensure_resource_for_property (resource, "nmm:composer", TRUE);
+         tracker_resource_set_string (composer, "nmm:artistName", composer_name);
+       }
       }
     }
   }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]