[rhythmbox] audioscrobbler: don't save submission queues without a username



commit 0998f13091766b246788501b708d469d088b5431
Author: Jonathan Matthew <jonathan d14n org>
Date:   Sun Mar 3 17:58:52 2013 +1000

    audioscrobbler: don't save submission queues without a username
    
    Queues saved without a username are saved as
    ~/.local/share/rhythmbox/audioscrobbler/submission-queues/servicename
    which prevents the creation of the directory used to store queues
    saved with a username.  This data can't be submitted to the service,
    so there's no point saving it.  Since it interferes with proper operation
    later on, remove such a file if we find one on startup.

 plugins/audioscrobbler/rb-audioscrobbler.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/plugins/audioscrobbler/rb-audioscrobbler.c b/plugins/audioscrobbler/rb-audioscrobbler.c
index 3beab0e..aa1079a 100644
--- a/plugins/audioscrobbler/rb-audioscrobbler.c
+++ b/plugins/audioscrobbler/rb-audioscrobbler.c
@@ -1104,6 +1104,18 @@ rb_audioscrobbler_load_queue (RBAudioscrobbler *audioscrobbler)
        char *end;
        gsize size;
 
+       /* ensure we don't have a queue file saved without a username */
+       pathname = g_build_filename (rb_user_data_dir (),
+                                    "audioscrobbler",
+                                    "submission-queues",
+                                    rb_audioscrobbler_service_get_name (audioscrobbler->priv->service),
+                                    NULL);
+       if (g_file_test (pathname, G_FILE_TEST_IS_REGULAR)) {
+               rb_debug ("deleting usernameless queue file %s", pathname);
+               unlink (pathname);
+       }
+       g_free (pathname);
+
        /* we don't really care about errors enough to report them here */
        pathname = g_build_filename (rb_user_data_dir (),
                                     "audioscrobbler",
@@ -1159,6 +1171,11 @@ rb_audioscrobbler_save_queue (RBAudioscrobbler *audioscrobbler)
                return TRUE;
        }
 
+       if (!audioscrobbler->priv->username) {
+               rb_debug ("can't save queue without a username");
+               return TRUE;
+       }
+
        str = g_string_new ("");
        for (l = audioscrobbler->priv->queue->head; l != NULL; l = g_list_next (l)) {
                AudioscrobblerEntry *entry;


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