[gnome-music/wip/jfelder/fix-playlist-renaming: 12/13] grltrackerplaylists: Check for playlist renaming failure



commit 4b957548c236d4789a0936d13e6f8c9ff0501f6e
Author: Jean Felder <jfelder src gnome org>
Date:   Tue Jan 7 20:09:35 2020 +0100

    grltrackerplaylists: Check for playlist renaming failure

 gnomemusic/grilowrappers/grltrackerplaylists.py | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/gnomemusic/grilowrappers/grltrackerplaylists.py b/gnomemusic/grilowrappers/grltrackerplaylists.py
index acd626a9..427096c6 100644
--- a/gnomemusic/grilowrappers/grltrackerplaylists.py
+++ b/gnomemusic/grilowrappers/grltrackerplaylists.py
@@ -22,6 +22,7 @@
 # code, but you are not obligated to do so.  If you do not wish to do so,
 # delete this exception statement from your version.
 
+import logging
 import time
 
 from gettext import gettext as _
@@ -34,6 +35,8 @@ from gnomemusic.coresong import CoreSong
 from gnomemusic.trackerwrapper import TrackerWrapper
 import gnomemusic.utils as utils
 
+logger = logging.getLogger(__name__)
+
 
 class GrlTrackerPlaylists(GObject.GObject):
 
@@ -418,11 +421,16 @@ class Playlist(GObject.GObject):
         self._window.notifications_popup.push_loading()
 
         def update_cb(conn, res, data):
-            # FIXME: Check for failure.
-            conn.update_finish(res)
-            # FIXME: Requery instead?
-            self.props.title = new_name
-            self._window.notifications_popup.pop_loading()
+            try:
+                conn.update_finish(res)
+            except GLib.Error as e:
+                logger.warning(
+                    "Unable to rename playlist from {} to {}: {}".format(
+                        self.props.title, new_name, e.message))
+            else:
+                self.props.title = new_name
+            finally:
+                self._window.notifications_popup.pop_loading()
 
         query = """
         INSERT OR REPLACE {


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