[gnome-music/wip/mschraal/tracker-change-tracking-fix-3-34: 1/2] grltrackerwrapper: Reuse Core{Album, Artist} on change



commit 126d24b3202fa075ea921fe901a739f0daa73136
Author: Marinus Schraal <mschraal gnome org>
Date:   Wed Oct 16 12:00:51 2019 +0200

    grltrackerwrapper: Reuse Core{Album,Artist} on change
    
    When checking for album or artist changes Music was constantly
    requerying these entities in Tracker, while they only need to be queried
    if not available. This made it impossible to correctly live update
    albums and is inefficient as well.
    
    Check for an existing Core{Album,Artist} before creating a new one and
    use it if available.

 gnomemusic/grilowrappers/grltrackerwrapper.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/gnomemusic/grilowrappers/grltrackerwrapper.py b/gnomemusic/grilowrappers/grltrackerwrapper.py
index fe5d5e63..ace4bb61 100644
--- a/gnomemusic/grilowrappers/grltrackerwrapper.py
+++ b/gnomemusic/grilowrappers/grltrackerwrapper.py
@@ -199,7 +199,11 @@ class GrlTrackerWrapper(GObject.GObject):
                 self._album_ids = album_ids
                 return
 
-            album = CoreAlbum(media, self._coremodel)
+            if media.get_id() in self._album_ids.keys():
+                album = self._album_ids[media.get_id()]
+            else:
+                album = CoreAlbum(media, self._coremodel)
+
             album_ids[media.get_id()] = album
 
         options = self._fast_options.copy()
@@ -248,7 +252,11 @@ class GrlTrackerWrapper(GObject.GObject):
                 self._artist_ids = artist_ids
                 return
 
-            artist = CoreArtist(media, self._coremodel)
+            if media.get_id() in self._artist_ids.keys():
+                artist = self._artist_ids[media.get_id()]
+            else:
+                artist = CoreArtist(media, self._coremodel)
+
             artist_ids[media.get_id()] = artist
 
         options = self._fast_options.copy()


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